﻿


layui.config({
    base: '/Scripts/CustoMcontrol/'
}).define(['form', 'layer', 'element', 'laydate', 'table', 'dictTableSelect', 'userTableSelect', 'colorpicker'], function (exports) {
    "use strict";





    var dictTableSelect = layui.dictTableSelect,
        userTableSelect = layui.userTableSelect,
        table = layui.table,
        layer = layui.layer,
        form = layui.form,
        element = layui.element,
        colorpicker = layui.colorpicker,
        laydate = layui.laydate;

    /**字典类型数据 */
    var dictClassList = null;
    /**字典集合 */
    var dictList = {};
    /**初始化编辑器*/
    var formEditorContainer = {};
    /**编辑器状态枚举*/
    const editorformstate =
    {
        //查看
        read: 0,
        //编辑
        edit: 1,
        //维护
        repair: 2
    };
    /**控件属性枚举 */
    var controlAttr = {
        //主键 
        id: 0,
        //标题
        title: 1,
        //控件类型
        tag: 2,
        //提示
        placeholder: 3,
        //默认值
        defaulttext: 4,
        //宽度
        width: 5,
        //只读
        isreadonly: 6,
        //隐藏
        display: 7,
        //必填项
        required: 8,
        //校验
        layverify: 9,
        //高度
        height: 10,
        //选项 放在控件列表属性attribute 第一位 否则 生成对象会导致其他属性无法赋值进去
        options: 11,
        //数字最大值: 12,
        //数字最小值: 13,
        //步长: 14,
        //日期类型
        datetype: 15,
        //日期格式
        dateformat: 16,
        //日期最大值
        datemax: 17,
        //日期最小值
        datemin: 18,
        //是否范围选择器
        daterange: 19,
        //星星个数: 20,
        //星星半数: 21,
        //是否全屏: 22,
        //自动播放: 23,
        //为空提示
        layReqtext: 24,
        //辅助文字
        wordaux: 25,
        //布局类型
        layouttype: 26,
        //开|关名称
        laytext: 27,
        //子元素 
        controls: 28,
        //字典类型 放在控件列表属性attribute 第二位 否则 生成对象会导致其他属性无法赋值进去
        dictclass: 29,
        //角色组
        rolegroup: 30,
        //用户类型
        userdept: 31,
        //选择类型
        selecttype: 32,
        //标题长度
        titlewidth: 33,
        //是否显示列
        isdisplaycolumn: 34,
        //字体大小
        textsize: 35,
        //字体颜色
        textcolour: 36,
        //合计到某某控件
        totaltocontrols: 37,
        //列表是否合计
        totalrow: 38,
        //是否显示value
        iscolumnvalue: 39,
        //switch隐藏值
        layvalue: 40,
        //下拉框是否开启自定义数据
        isowndefinition: 41,
        //合计比例到某某控件
        totalproportion: 42,
        //联动事件
        linkage: 43,
        //查看隐藏
        seehide: 44,
        //数据类型
        textdatatype:45,
        //数据长度，整数长度，浮点保留位数
        textdatalength: 46,
        //是否导出excel文件
        isexportexcel: 47,
        //数字最大值
        numbermax: 48,
        //数字最小值
        numbermin: 49,
        //是否可以添加多条
        issureaddmultiple: 50,
        //默认个数 必须在issureaddmultiple后面。
        defaultmultiple: 51,
        //最大条目
        multiplemax:52

    };

    /**私有方法,初始数据 */
    var formEditor = function (editortype, body) {
        /**实例变量 */
        var newFormEditor = this;
        //编辑器容器的div
        this.thisdivid = 'formDesignerForm';
        /** 选择的控件元素 索引 */
        this.SelectIndexControl = [];
        /**编辑器的大容器 */
        this.container = body;
        /**编辑模式 表单的值 */
        this.values = {};
        /**回调方法集合 */
        this.callback = {};
        /**模版ID */
        this.TemplateID = "";
        /**合计到 */
        this.totalToIdValue = {};
        /** 标题 */
        this.title = '';
        this.taskformtable = {};
        /**编辑器左侧控件内容 */
        this.controls = [
            {
                text: '输入型组件',
                controls: [
                    {
                        tag: 'input',
                        text: '文本框',
                        domtype: 'input',
                        attribute: [controlAttr.id, controlAttr.title, controlAttr.tag, controlAttr.totaltocontrols, controlAttr.totalproportion, controlAttr.totalrow, controlAttr.textsize, controlAttr.textcolour, controlAttr.placeholder, controlAttr.defaulttext, controlAttr.width, controlAttr.titlewidth, controlAttr.isdisplaycolumn, controlAttr.isreadonly, controlAttr.display, controlAttr.required, controlAttr.layverify, controlAttr.layReqtext, controlAttr.wordaux, controlAttr.layouttype, controlAttr.textdatatype, controlAttr.textdatalength, controlAttr.isexportexcel, controlAttr.numbermax, controlAttr.numbermin],
                        html: '<label class="layui-form-label"></label> <div class="layui-input-block"> <input  type="text"    class="layui-input"    lay-vertype="tips"></input></div>'
                    },
                    {
                        tag: 'password',
                        text: '密码框',
                        domtype: 'input',
                        attribute: [controlAttr.id, controlAttr.title, controlAttr.tag, controlAttr.textsize, controlAttr.textcolour, controlAttr.placeholder, controlAttr.defaulttext, controlAttr.width, controlAttr.titlewidth, controlAttr.isreadonly, controlAttr.display, controlAttr.required, controlAttr.layverify, controlAttr.layReqtext, controlAttr.wordaux, controlAttr.layouttype],
                        html: '<label class="layui-form-label"></label> <div class="layui-input-block"> <input   type="password"   class="layui-input"   lay-vertype="tips"></input></div>'
                    },
                    {
                        tag: 'textarea',
                        text: '多行文本',
                        domtype: 'textarea',
                        attribute: [controlAttr.id, controlAttr.title, controlAttr.tag, controlAttr.textsize, controlAttr.textcolour, controlAttr.placeholder, controlAttr.defaulttext, controlAttr.width, controlAttr.isreadonly, controlAttr.display, controlAttr.required, controlAttr.layverify, controlAttr.layReqtext, controlAttr.wordaux, controlAttr.layouttype, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label> <div class="layui-input-block"><textarea  class="layui-textarea"></textarea></div>'
                    }

                ]
            }
            ,
            {
                text: '选择型组件',
                controls: [
                    {
                        tag: 'select',
                        text: '下拉框',
                        domtype: 'select',
                        attribute: [controlAttr.options, controlAttr.dictclass, controlAttr.isowndefinition, controlAttr.iscolumnvalue, controlAttr.textsize, controlAttr.textcolour, controlAttr.id, controlAttr.title, controlAttr.tag, controlAttr.defaulttext, controlAttr.width, controlAttr.isdisplaycolumn, controlAttr.titlewidth, controlAttr.display, controlAttr.required, controlAttr.layverify, controlAttr.layReqtext, controlAttr.wordaux, controlAttr.layouttype, controlAttr.linkage, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label> <div class="layui-input-block"><select    lay-search=""  lay-vertype="tips"></select></div>'
                    }
                    ,
                    {
                        tag: 'radio',
                        text: '单选框',
                        domtype: 'input',
                        attribute: [controlAttr.options, controlAttr.dictclass, controlAttr.iscolumnvalue, controlAttr.id, controlAttr.textsize, controlAttr.textcolour, controlAttr.title, controlAttr.tag, controlAttr.isdisplaycolumn, controlAttr.titlewidth, controlAttr.defaulttext, controlAttr.display, controlAttr.wordaux, controlAttr.layouttype, controlAttr.linkage, controlAttr.seehide, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label><div class="layui-input-block"></div> '
                    },
                   
                    {
                        tag: 'checkbox',
                        text: '复选框',
                        domtype: 'input',
                        attribute: [controlAttr.options, controlAttr.dictclass, controlAttr.iscolumnvalue, controlAttr.id, controlAttr.textsize, controlAttr.textcolour, controlAttr.title, controlAttr.tag, controlAttr.isdisplaycolumn, controlAttr.titlewidth, controlAttr.defaulttext, controlAttr.display, controlAttr.required, controlAttr.wordaux, controlAttr.layouttype, controlAttr.layReqtext, controlAttr.linkage, controlAttr.seehide, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label><div class="layui-input-block"></div> '
                    },
                    {
                        tag: 'switch',
                        text: '开关',
                        domtype: 'input',
                        attribute: [controlAttr.id, controlAttr.title, controlAttr.tag, controlAttr.totalrow, controlAttr.iscolumnvalue, controlAttr.layvalue, controlAttr.textsize, controlAttr.textcolour, controlAttr.titlewidth, controlAttr.defaulttext, controlAttr.isdisplaycolumn, controlAttr.display, controlAttr.wordaux, controlAttr.layouttype, controlAttr.laytext, controlAttr.linkage, controlAttr.seehide, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label><div class="layui-input-block"><input  type="checkbox" value="true"  lay-skin="switch"></input></div> '
                    },
                    {
                        tag: 'date',
                        text: ' 日期',
                        domtype: 'input',
                        attribute: [controlAttr.id, controlAttr.title, controlAttr.tag, controlAttr.textsize, controlAttr.textcolour, controlAttr.titlewidth, controlAttr.placeholder, controlAttr.isdisplaycolumn, controlAttr.defaulttext, controlAttr.display, controlAttr.required, controlAttr.layReqtext, controlAttr.wordaux, controlAttr.layouttype, controlAttr.datetype, controlAttr.datemax, controlAttr.datemin, controlAttr.daterange, controlAttr.dateformat, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label><div class="layui-input-block"><input  type="text" class="layui-input"></input></div> '

                    }

                ]
            }
            ,
            {
                text: '布局组件',
                controls: [
                    {
                        tag: 'row',
                        text: '行',
                        domtype: 'div',
                        attribute: [controlAttr.id, controlAttr.tag, controlAttr.controls, controlAttr.issureaddmultiple, controlAttr.defaultmultiple, controlAttr.multiplemax],
                        html: '<div class="layui-form"></div>'

                    },
                    {
                        tag: 'title',
                        text: '标题分割线',
                        domtype: 'legend',
                        attribute: [controlAttr.id, controlAttr.tag, controlAttr.title, controlAttr.textsize, controlAttr.textcolour],
                        html: '<fieldset class="layui-elem-field layui-field-title"><legend></legend></fieldset>'
                    }

                ]
            }
            ,
            {
                text: '字典',
                controls: [
                    {

                        tag: 'user',
                        text: '用户选择',
                        domtype: 'input',
                        attribute: [controlAttr.id, controlAttr.title, controlAttr.tag, controlAttr.iscolumnvalue, controlAttr.textsize, controlAttr.textcolour, controlAttr.placeholder, controlAttr.isdisplaycolumn, controlAttr.width, controlAttr.titlewidth, controlAttr.display, controlAttr.required, controlAttr.layReqtext, controlAttr.wordaux, controlAttr.layouttype, controlAttr.rolegroup, controlAttr.userdept, controlAttr.selecttype, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label> <div class="layui-input-block"> <input ts-selected=""  type="text" readonly  class="layui-input"    lay-vertype="tips"></input></div>'
                    },

                    {
                        tag: 'dict',
                        text: '字典选择',
                        domtype: 'input',
                        attribute: [controlAttr.dictclass, controlAttr.id, controlAttr.textsize, controlAttr.iscolumnvalue, controlAttr.textcolour, controlAttr.title, controlAttr.tag, controlAttr.isdisplaycolumn, controlAttr.placeholder, controlAttr.width, controlAttr.titlewidth, controlAttr.display, controlAttr.required, controlAttr.layReqtext, controlAttr.wordaux, controlAttr.layouttype, controlAttr.selecttype, controlAttr.isexportexcel],
                        html: '<label class="layui-form-label"></label> <div class="layui-input-block"> <input ts-selected=""  type="text" readonly  class="layui-input"    lay-vertype="tips"></input></div>'
                    }
                ]
            }
        ];
        /**
         * 输出的数据
         * */
        this.putjson = [];

        /**右侧属性数据 与控件属性 枚举keyi 对应 */
        this.rightAttributes =
        {
            //属性ID
            id: {
                dom: null,
                text: null
            },

            //标题
            title: {
                dom: null,
                text: null
            },

            //控件类型
            tag: {
                dom: null,
                text: null
            },
            //是否可以添加多条数据
            issureaddmultiple: {
                dom: null,
                text: null
            },
            //添加多条数据默认个数
            defaultmultiple: {
                dom: null,
                text: null
            },
            //添加最大条目
            multiplemax: {
                dom: null,
                text: null
            },
            //文本框数据类型
            textdatatype: {
                dom: null,
                text: null
            },
            //数据长度，整数长度，浮点保留位数
            textdatalength: {
                dom: null,
                text: null
            },
            //数字最小值
            numbermax: {
                dom: null,
                text: null
            },
            //数字最大值
            numbermin: {
                dom: null,
                text: null
            },
            //布局类型
            layouttype: {
                dom: null,
                text: null
            },

            //字体大小
            textsize: {
                dom: null,
                text: null
            },

            //字体颜色
            textcolour: {
                dom: null,
                text: null
            },

            //提示
            placeholder: {
                dom: null,
                text: null
            },
            defaulttext: {
                dom: null,
                text: null
            },
            //宽度
            width: {
                dom: null,
                text: null
            },
            //高度
            height: {
                dom: null,
                text: null
            },
            //标题宽度
            titlewidth: {
                dom: null,
                text: null
            },
            //是否在列表显示
            isdisplaycolumn: {
                dom: null,
                text: null
            },
            //是否导出excel
            isexportexcel: {
                dom: null,
                text: null
            },
            //列表显示text还是value
            iscolumnvalue: {
                dom: null,
                text: null
            },
            //列表合计
            totalrow: {
                dom: null,
                text: null
            },
            //下拉框开启
            isowndefinition: {
                dom: null,
                text: null
            },
            //只读
            isreadonly: {
                dom: null,
                text: null
            },
            //隐藏
            display: {
                dom: null,
                text: null
            },

            //查看隐藏
            seehide: {
                dom: null,
                text: null
            },
            //必填
            required: {
                dom: null,
                text: null
            },
            //为空提示
            layReqtext: {
                dom: null,
                text: null
            },
            //校验
            layverify: {
                dom: null,
                text: null
            },
            //开关内容
            laytext: {
                dom: null,
                text: null
            },
            //开关隐藏值
            layvalue: {
                dom: null,
                text: null
            }
            ,
            //日期类型
            datetype: {
                dom: null,
                text: null
            },
            //日期格式
            dateformat: {
                dom: null,
                text: null
            },

            //时间是否为范围选择器
            daterange: {
                dom: null,
                text: null
            },
            //日期最大值
            datemax: {
                dom: null,
                text: null
            },

            //日期最小值
            datemin: {
                dom: null,
                text: null
            },
            //辅助文本
            wordaux: {
                dom: null,
                text: null
            },
            //绑定字典
            dictclass: {
                dom: null,
                text: null
            }
            ,
            //选项
            options: {
                dom: null,
                text: null
            },
            //角色组
            rolegroup: {
                dom: null,
                text: null
            },
            //用户类型
            userdept: {
                dom: null,
                text: null
            },
            //选择类型
            selecttype: {
                dom: null,
                text: null
            },
            //合计到
            totaltocontrols: {
                dom: null,
                text: null
            },
            //合计比例
            totalproportion: {
                dom: null,
                text: null
            },

            //联动事件
            linkage: {
                dom: null,
                text: null
            }



        };

        /**编辑器状态 */
        this.editortype = editortype;
        $('head').append("<link href=\"/Scripts/Layui/formEditor/css/layuiFormEditor.css\" rel=\"stylesheet\" /> <script src='/Scripts/Layui/formEditor/js/Sortable.js'>");


        ///*导入PDF导出*/
        //$('head').append("<script src=\"/Scripts/Layui/exportPdf/html2canvas.js\"/><script src=\"/Scripts/Layui/exportPdf/es6-promise.auto.min.js\"/>  <script src='/Scripts/Layui/exportPdf/jspdf.debug.js'></script>");


        if (editortype === editorformstate.repair) {
            //输出基本样式 还有 基本库
            //初始化编辑器
            if (IsEmpty(body)) {
                body = $('body');
            }


            body.addClass('layui-editor-body');
            var html = '<div id="formdesigner" class="layui-layout" style="height: 100%; width: 100%;">';
            var leftSortableid = [];
            //加载左侧组件
            html += '<div class="layui-side" style="width:260px;">';
            html += '   <div class="layui-side-scroll" style="width:260px;">';
            html += '       <div class="layui-tab layui-tab-brief" lay-filter="components-list">';
            html += '           <ul class="layui-tab-title">';
            html += '               <li class="layui-this">组件</li>';

            //html += '               <li>数据源</li>';

            html += '           </ul>';
            html += '       <div class="layui-tab-content">';
            html += '           <div class="layui-tab-item layui-show">';
            //加载组件列表
            html += '               <div class="components-list" id="components-form-list">';
            for (var i = 0; i < newFormEditor.controls.length; i++) {

                html += '               <div class="components-title">' + newFormEditor.controls[i].text + ' </div>';
                html += '               <div class="components-draggable" id="c' + (i + 1) + '">';
                leftSortableid.push('c' + (i + 1));
                //加载控件
                for (var s = 0; s < newFormEditor.controls[i].controls.length; s++) {
                    html += '           <div class="components-item" draggable="false" data-tag="' + newFormEditor.controls[i].controls[s].tag + '">';
                    html += '               <div class="components-body">';
                    html += '                   <i class="icon iconfont icon-input"></i>' + newFormEditor.controls[i].controls[s].text;
                    html += '               </div>';
                    html += '           </div>';
                }
                html += '             </div>';
            }
            html += '             </div>';
            //加载左侧列表结束
            html += '           </div>';
            html += '           <div class="layui-tab-item components-list" id="components-form-list">开发中...</div>';
            html += '       </div>';
            html += '     </div>';
            html += '   </div>';
            html += '</div>';
            //加载主体内容
            html += '<div class="layui-form" style="height:100%;">';
            html += '   <div style="display:none;" class="widget-view-action" id="widget-view-action"><!--<i class="layui-icon layui-icon-file"></i>--><i class="layui-icon layui-icon-delete"></i></div>';
            html += '   <div style="display:none;" class="widget-view-drag" id="widget-view-drag"><i class="layui-icon layui-icon-screen-full"></i></div>';
            html += '   <div class="layui-form" id="' + newFormEditor.thisdivid + '" lay-filter="' + newFormEditor.thisdivid + '">';
            html += '       <div class="layui-row layui-empty">从左侧拖拽控件到此设计区域来添加字段</div>';
            html += '   </div>';
            html += '</div>';
            //加载右侧属性值
            html += '<div class="layui-side-right" style="background-color:#fff;">';
            html += '   <div class="layui-side-scroll" id="right_Attributes_Content" style="width: 360px;">';
            html += '       <div class="layui-form" lay-filter="form-attr">';
            html += '           <div class="layui-tab layui-tab-brief">';
            html += '               <ul class="layui-tab-title">';
            html += '                   <li class="layui-this">字段设置</li>';
            html += '                   <li>表单设置</li>';
            html += '               </ul>';
            html += '                <div class="layui-tab-content">';
            html += '                   <div class="layui-tab-item layui-show"  id="columnProperty">';
            //列表属性菜单数据
            html += '                   </div>';
            html += '                   <div class="layui-tab-item" id="formProperty">';

            html += '<button id="editorpreview" class="layui-btn layui-btn-radius" type="button">预览模板</button>';

            html += '<button id="saveorparoperty" class="layui-btn layui-btn-radius" type="button">保存模板</button>';

            html += '<button id="editorparoperty" class="layui-btn layui-btn-radius" type="button">导出数据</button>';



            //表单菜单数据
            html += '                   </div>';
            html += '                </div>';
            html += '          </div>';
            html += '      </div>';
            html += '   </div>';
            html += '</div>';
            html += '</div>'

            body.append(html);
            //form.render();
            //渲染左侧控件元素
            element.render('tab', 'components-list');
            //注册控件拉动到右侧事件
            //初始化属性栏目
            rightAttributesNew();
            //导出json
            $("#editorparoperty").on('click', function () {
                newFormEditor.exportJson();
            });

            $("#editorpreview").on('click', function () {
                newFormEditor.preview();
            });


            /*保存函数*/
            $("#saveorparoperty").on('click', function () {
                newFormEditor.saveTemplate();
            });



            var columnProperty = $('#columnProperty');
            for (var i in newFormEditor.rightAttributes) {
                if (!IsEmpty(newFormEditor.rightAttributes[i].dom)) {
                    columnProperty.append(newFormEditor.rightAttributes[i].dom);
                    newFormEditor.rightAttributes[i].dom.hide();
                }
            }




            //渲染 右侧属性
            form.render(null, 'form-attr')



            //注册删除单击事件
            $("#widget-view-action .layui-icon-delete").on("click", function () {
                if (newFormEditor.SelectIndexControl.length < 1) {
                    return;
                }

                var index = 0;
                var putcontrolsjson = newFormEditor.putjson;
                var divtscontainer = $("#" + newFormEditor.thisdivid);
                var newIndex = [];
                //排序 解决子元素排序问题 
                for (var i in newFormEditor.SelectIndexControl) {
                    if ((i + 1) < newFormEditor.SelectIndexControl.length) {
                        divtscontainer = putcontrolsjson[newFormEditor.SelectIndexControl[i]].tagdom;
                        putcontrolsjson = putcontrolsjson[newFormEditor.SelectIndexControl[i]].controls;
                        newIndex.push(newFormEditor.SelectIndexControl[i]);
                    }
                    else {
                        //putcontrolsjson = putcontrolsjson[newFormEditor.SelectIndexControl[i]];
                        index = newFormEditor.SelectIndexControl[i];
                        newIndex.push(putcontrolsjson.length - 1);
                    }
                }

                //获取上级节点
                if (index >= 0 && index < putcontrolsjson.length) {
                    //移动位置并且删除
                    newFormEditor.sortputjson(newIndex, newFormEditor.SelectIndexControl, putcontrolsjson);

                    //删除最后一个元素
                    var popjson = putcontrolsjson.pop();
                    //重新设置焦点
                    if (index >= 0 && index < putcontrolsjson.length) {
                        putcontrolsjson[index].tagdom.click();
                    }
                    else if ((index - 1) >= 0 && (index - 1) < putcontrolsjson.length) {
                        putcontrolsjson[index - 1].tagdom.click();
                    } else if ((index + 1) >= 0 && (index + 1) < putcontrolsjson.length) {
                        putcontrolsjson[index + 1].tagdom.click();
                    }
                    else {
                        //移植到根目录 并且隐藏 这样就不用再生产dom了
                        $("#" + newFormEditor.thisdivid + " .active").removeClass('active');
                        var widgetviewaction = $("#widget-view-action");
                        var widgetviewdrag = $("#widget-view-drag");
                        widgetviewaction.hide();
                        widgetviewdrag.hide();
                        $('#formdesigner').append(widgetviewaction);
                        $('#formdesigner').append(widgetviewdrag);
                        //移植提示信息
                        divtscontainer.append('<div class="layui-row layui-empty">从左侧拖拽控件到此设计区域来添加字段</div>');
                        newFormEditor.SelectIndexControl = [];

                        for (var i in newFormEditor.rightAttributes) {
                            if (!IsEmpty(newFormEditor.rightAttributes[i].dom)) {
                                newFormEditor.rightAttributes[i].dom.hide();
                            }

                        }

                    }
                    //删除html 元素
                    if (popjson !== undefined) {
                        popjson.tagdom.remove();
                    }

                }

            });

            //注册控件拖拉事件
            if (leftSortableid.length > 0) {
                for (var f = 0; f < leftSortableid.length; f++) {
                    new Sortable(document.getElementById(leftSortableid[f]), {
                        group: {
                            name: 'leftSortableid',
                            pull: 'clone',
                            put: false
                        },
                        animation: 150,
                        sort: false

                    });
                }


            }

            //注册编辑器内容排序新增 删除 修改 事件
            new Sortable(document.getElementById(newFormEditor.thisdivid), {
                group: {
                    name: 'editcontent',
                    pull: false,
                    put: 'leftSortableid'
                },
                animation: 150,
                onAdd: function (evt) {
                    var newindex = 0;
                    if ($('#' + newFormEditor.thisdivid).children('.layui-row.layui-empty').length < 1) {
                        //添加序列号
                        newindex = evt.newIndex;
                    }
                    newFormEditor.dragcontrol($(evt.item), [newindex], newFormEditor.putjson)
                },
                onUpdate: function (evt) {

                    newFormEditor.sortputjson([evt.newIndex], [evt.oldIndex], newFormEditor.putjson);
                    //设置当前选择
                    newFormEditor.SelectIndexControl = [evt.newIndex];

                }

            });
        }
        else {
            body.addClass("layui-form");
            body.attr("lay-filter", newFormEditor.thisdivid);
        }

        function getDivAndInpAndLblDom() {
            if (newFormEditor.SelectIndexControl.length < 1) {
                return null;
            }
            var index = 0;
            var putcontrolsjson = newFormEditor.putjson;
            for (var i in newFormEditor.SelectIndexControl) {
                if ((i + 1) < newFormEditor.SelectIndexControl.length) {
                    putcontrolsjson = putcontrolsjson[newFormEditor.SelectIndexControl[i]].controls;
                }
                else {
                    //putcontrolsjson = putcontrolsjson[newFormEditor.SelectIndexControl[i]];
                    index = newFormEditor.SelectIndexControl[i];
                }
            }

            //搜索数据元素类型
            //搜索dom
            var divdom = putcontrolsjson[index].tagdom;
            if (putcontrolsjson[index].tag === 'row') {

                return [divdom, $('.layui-row.layui-empty'), {}, {}, putcontrolsjson[index], index]
            }

            if (putcontrolsjson[index].tag === 'title') {

                return [divdom, {}, {}, divdom.find(putcontrolsjson[index].domtype), putcontrolsjson[index], index]

            }

            var inpdivdom = divdom.find('div[class^="layui-input-block"]');
            if (inpdivdom.length < 1) {
                inpdivdom = divdom.find('div[class^="layui-input-inline"]');
            }
            var inpdom = inpdivdom.find(putcontrolsjson[index].domtype);
            var lbldom = divdom.find('label[class^="layui-form-label"]');

            return [divdom, inpdivdom, inpdom, lbldom, putcontrolsjson[index], index]
        }

        /**初始化右侧属性栏 */
        function rightAttributesNew() {
            /**根据当前选择 搜索控件 */



            //文本框更改文字事件
            var oneventname = '';

            if (!!window.ActiveXObject || "ActiveXObject" in window) {
                //IE
                oneventname = 'propertychange';
            } else {
                //非IE
                oneventname = 'oninput';
            }
            //生成属性列表
            //生成属性列表dom

            //生成ID标识
            newFormEditor.rightAttributes.id.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.id.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.id.dom.html('<label class="layui-form-label">标识</label><div class="layui-input-block"><input name="id" class="layui-input" required="" type="text" placeholder="请输入控件标识" value="" autocomplete="off" lay-verify="required"> </div></div>');
            newFormEditor.rightAttributes.id.dom.find('input[name^="id"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                //文本更改
                var value = $(this).val();

                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];



                selectdata.id = value;
                if (selectdata.tag !== 'row') {
                    inpdom.attr("name", selectdata.id)
                }
                divdom.attr("id", selectdata.id);
                divdom.attr('data-id', selectdata.id);
                divdom.data('id', selectdata.id);

                if (selectdata.tag === 'date') {
                    //增加一个ID时间ID
                    inpdom.attr('id', 'date_' + selectdata.id)
                }

            });
            //取值 赋值方法
            newFormEditor.rightAttributes.id.text = function () {
                if (newFormEditor.rightAttributes.id.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "id": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.id;
                    }
                }

            }

            //生成标题
            newFormEditor.rightAttributes.title.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.title.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.title.dom.html('<label class="layui-form-label">标题</label><div class="layui-input-block"><input name="title" class="layui-input" required="" type="text" placeholder="请输入控件标题" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.title.dom.find('input[name^="title"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.title = value;

                lbldom.html(value);

            });
            //取值 赋值方法
            newFormEditor.rightAttributes.title.text = function () {
                if (newFormEditor.rightAttributes.title.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "title": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.title;
                    }
                }
            }


            //生成控件类型
            newFormEditor.rightAttributes.tag.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.tag.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.tag.dom.html('<label class="layui-form-label">控件类型</label><div class="layui-input-block"><input name="tag" class="layui-input" required="" type="text" disabled value="" autocomplete="off" lay-verify="required"> </div></div>');
            newFormEditor.rightAttributes.tag.text = function () {
                if (newFormEditor.rightAttributes.tag.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (!IsEmpty(arguments[0])) {
                            for (var i in newFormEditor.controls) {
                                for (var s in newFormEditor.controls[i].controls) {
                                    if (newFormEditor.controls[i].controls[s].tag === arguments[0]) {
                                        form.val('form-attr', { "tag": newFormEditor.controls[i].controls[s].text });
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        //转换数据
                        if (!IsEmpty(data.tag)) {
                            for (var i in newFormEditor.controls) {
                                for (var s in newFormEditor.controls[i].controls) {
                                    if (newFormEditor.controls[i].controls[s].tag === data.tag) {
                                        return newFormEditor.controls[i].controls[s].text;
                                    }
                                }
                            }
                        }
                        return "";
                    }
                }

            }

            //是否可以添加多条数据issureaddmultiple
            
            newFormEditor.rightAttributes.issureaddmultiple.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.issureaddmultiple.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.issureaddmultiple.dom.html('<label class="layui-form-label">是否多条</label><div class="layui-input-block"><input name="issureaddmultiple" type="checkbox" lay-filter="issureaddmultiple" lay-skin="switch" lay-text="是|否"> </div></div>');
            form.on('switch(issureaddmultiple)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                var value = this.checked;
                selectdata.issureaddmultiple = value;
                if (this.checked) {
                    //显示最大条目，默认条目
                    newFormEditor.rightAttributes.defaultmultiple.dom.show();
                    newFormEditor.rightAttributes.multiplemax.dom.show();


                }
                else
                {
                    //隐藏最大条目，默认条目

                    newFormEditor.rightAttributes.defaultmultiple.dom.hide();
                    newFormEditor.rightAttributes.multiplemax.dom.hide();
                    newFormEditor.rightAttributes.defaultmultiple.dom.find("input[name^='defaultmultiple']").val("");
                    newFormEditor.rightAttributes.multiplemax.dom.find("input[name^='multiplemax']").val("");


                }


            });
            newFormEditor.rightAttributes.issureaddmultiple.text = function () {
                if (newFormEditor.rightAttributes.issureaddmultiple.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "issureaddmultiple": arguments[0] });

                            if (arguments[0] === true || arguments[0]==='true') {
                                //显示最大条目，默认条目
                                newFormEditor.rightAttributes.defaultmultiple.dom.show();
                                newFormEditor.rightAttributes.multiplemax.dom.show();
                            }
                            else {
                                //隐藏最大条目，默认条目
                                newFormEditor.rightAttributes.defaultmultiple.dom.hide();
                                newFormEditor.rightAttributes.multiplemax.dom.hide();
                                newFormEditor.rightAttributes.defaultmultiple.dom.find("input[name^='defaultmultiple']").val("");
                                newFormEditor.rightAttributes.multiplemax.dom.find("input[name^='multiplemax']").val("");
                            }
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.issureaddmultiple === 'on' ? true : false;
                    }
                }
            };






            //添加多条数据默认个数 defaultmultiple
            

            newFormEditor.rightAttributes.defaultmultiple.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.defaultmultiple.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.defaultmultiple.dom.html('<label class="layui-form-label">默认条目</label><div class="layui-input-block"><input name="defaultmultiple" class="layui-input" required="" type="text" placeholder="请输入整数" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.defaultmultiple.dom.find('input[name^="defaultmultiple"]').on('input ' + oneventname, function () {
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.defaultmultiple = value;

            });
            //取值 赋值方法
            newFormEditor.rightAttributes.defaultmultiple.text = function () {
                if (newFormEditor.rightAttributes.defaultmultiple.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "defaultmultiple": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.defaultmultiple;
                    }
                }
            }



            //添加最大条目       multiplemax 


            newFormEditor.rightAttributes.multiplemax.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.multiplemax.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.multiplemax.dom.html('<label class="layui-form-label">最大条目</label><div class="layui-input-block"><input name="multiplemax" class="layui-input" required="" type="text" placeholder="请输入整数" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.multiplemax.dom.find('input[name^="multiplemax"]').on('input ' + oneventname, function () {
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.multiplemax = value;

            });
            //取值 赋值方法
            newFormEditor.rightAttributes.multiplemax.text = function () {
                if (newFormEditor.rightAttributes.multiplemax.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "multiplemax": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.multiplemax;
                    }
                }
            }









            //文本框数据类型textdatatype


            newFormEditor.rightAttributes.textdatatype.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.textdatatype.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.textdatatype.dom.html('<label class="layui-form-label">数据类型</label><div class="layui-input-block"><select name="textdatatype" lay-filter="textdatatype"><option value="">默认</option><option value="integer">整数</option><option value="float">浮点</option></select></div ></div > ');

            form.on('select(textdatatype)', function (data) {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                selectdata.textdatatype = data.value;
                switch (selectdata.textdatatype) {
                    case "integer":
                        newFormEditor.rightAttributes.textdatalength.dom.find("label").html("整数长度");
                        newFormEditor.rightAttributes.numbermin.dom.find("input[name^='numbermin']").attr("placeholder", "请输入整数");
                        newFormEditor.rightAttributes.numbermax.dom.find("input[name^='numbermax']").attr("placeholder", "请输入整数");
                        newFormEditor.rightAttributes.numbermax.dom.show();
                        newFormEditor.rightAttributes.numbermin.dom.show();
                        break;
                    case "float":
                        newFormEditor.rightAttributes.textdatalength.dom.find("label").html("浮点位数");


                        newFormEditor.rightAttributes.numbermin.dom.find("input[name^='numbermin']").attr("placeholder", "请输入整数或浮点数");
                        newFormEditor.rightAttributes.numbermax.dom.find("input[name^='numbermax']").attr("placeholder", "请输入整数或浮点数");
                        
                        newFormEditor.rightAttributes.numbermax.dom.show();
                        newFormEditor.rightAttributes.numbermin.dom.show();
                        break;
                    default:
                        newFormEditor.rightAttributes.textdatalength.dom.find("label").html("数据长度");
                        newFormEditor.rightAttributes.numbermax.dom.find("input[name^='numbermax']").val("");
                        newFormEditor.rightAttributes.numbermin.dom.find("input[name^='numbermin']").val("");

                        newFormEditor.rightAttributes.numbermax.dom.hide();
                        newFormEditor.rightAttributes.numbermin.dom.hide();
                        break;
                }


            });
            newFormEditor.rightAttributes.textdatatype.text = function () {
                if (newFormEditor.rightAttributes.textdatatype.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "textdatatype": arguments[0] });

                        switch (arguments[0]) {
                            case "integer":
                                newFormEditor.rightAttributes.textdatalength.dom.find("label").html("整数长度");
                                newFormEditor.rightAttributes.numbermax.dom.show();
                                newFormEditor.rightAttributes.numbermin.dom.show();
                                //请输入整数
                                newFormEditor.rightAttributes.numbermin.dom.find("input[name^='numbermin']").attr("placeholder", "请输入整数");
                                newFormEditor.rightAttributes.numbermax.dom.find("input[name^='numbermax']").attr("placeholder", "请输入整数");
                                break;
                            case "float":
                                newFormEditor.rightAttributes.textdatalength.dom.find("label").html("浮点位数");
                                newFormEditor.rightAttributes.numbermin.dom.find("input[name^='numbermin']").attr("placeholder", "请输入整数或浮点数");
                                newFormEditor.rightAttributes.numbermax.dom.find("input[name^='numbermax']").attr("placeholder", "请输入整数或浮点数");
                                newFormEditor.rightAttributes.numbermax.dom.show();
                                newFormEditor.rightAttributes.numbermin.dom.show();
                       

                                break;
                            default:
                                newFormEditor.rightAttributes.textdatalength.dom.find("label").html("数据长度");
                                //隐藏最大值、最小值
                                newFormEditor.rightAttributes.numbermax.dom.find("input[name^='numbermax']").val("");
                                newFormEditor.rightAttributes.numbermin.dom.find("input[name^='numbermin']").val("");
                                newFormEditor.rightAttributes.numbermax.dom.hide();
                                newFormEditor.rightAttributes.numbermin.dom.hide();

                                break;
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.textdatatype;
                    }
                }
            };


            //小数点位数 textdatalength

            newFormEditor.rightAttributes.textdatalength.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.textdatalength.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.textdatalength.dom.html('<label class="layui-form-label">数据长度</label><div class="layui-input-block"><input name="textdatalength" class="layui-input" required="" type="text" placeholder="请输入整数" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.textdatalength.dom.find('input[name^="textdatalength"]').on('input ' + oneventname, function () {
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.textdatalength = value;

            });
            //取值 赋值方法
            newFormEditor.rightAttributes.textdatalength.text = function () {
                if (newFormEditor.rightAttributes.textdatalength.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "textdatalength": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.textdatalength;
                    }
                }
            }



            //数字最大值，numbermax

            newFormEditor.rightAttributes.numbermax.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.numbermax.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.numbermax.dom.html('<label class="layui-form-label">数字最大值</label><div class="layui-input-block"><input name="numbermax" class="layui-input" required="" type="text" placeholder="请输入整数" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.numbermax.dom.find('input[name^="numbermax"]').on('input ' + oneventname, function () {
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.numbermax = value;

            });
            //取值 赋值方法
            newFormEditor.rightAttributes.numbermax.text = function () {
                if (newFormEditor.rightAttributes.numbermax.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "numbermax": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.numbermax;
                    }
                }
            }







            //最小值numbermin


            newFormEditor.rightAttributes.numbermin.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.numbermin.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.numbermin.dom.html('<label class="layui-form-label">数字最小值</label><div class="layui-input-block"><input name="numbermin" class="layui-input" required="" type="text" placeholder="请输入整数" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.numbermin.dom.find('input[name^="numbermin"]').on('input ' + oneventname, function () {
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.numbermin = value;

            });
            //取值 赋值方法
            newFormEditor.rightAttributes.numbermin.text = function () {
                if (newFormEditor.rightAttributes.numbermin.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "numbermin": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.numbermin;
                    }
                }
            }









            //生成提示
            newFormEditor.rightAttributes.placeholder.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.placeholder.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.placeholder.dom.html('<label class="layui-form-label">默认提示</label><div class="layui-input-block"><input name="placeholder" class="layui-input" required="" type="text" placeholder="请输入提示" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.placeholder.dom.find('input[name^="placeholder"]').on('input ' + oneventname, function () {


                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                //搜索dom
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.placeholder = value;

                inpdom.attr("placeholder", value)

            });

            newFormEditor.rightAttributes.placeholder.text = function () {
                if (newFormEditor.rightAttributes.placeholder.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "placeholder": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.placeholder;
                    }
                }
            }

            //默认值defaultText

            newFormEditor.rightAttributes.defaulttext.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.defaulttext.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.defaulttext.dom.html('<label class="layui-form-label">默认值</label><div class="layui-input-block"><input name="defaulttext" class="layui-input" required="" type="text" placeholder="请输入默认值" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.defaulttext.dom.find('input[name^="defaulttext"]').on('input ' + oneventname, function () {



                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.defaulttext = value;

                //默认值
                if (selectdata.tag === 'checkbox' || selectdata.tag === 'radio') {
                    var defaulttext = [];
                    if (value.indexOf(',') > -1) {
                        defaulttext = value.split(',');
                    }
                    else {
                        defaulttext = [value];
                    }

                    if (inpdom.length > 0) {
                        inpdom.val(defaulttext);
                    }
                    if (selectdata.tag === 'checkbox') {

                        form.render('checkbox', newFormEditor.thisdivid);
                    }
                    else {
                        form.render('radio', newFormEditor.thisdivid);
                    }
                }
                else {
                    switch (selectdata.tag) {
                        case 'switch':
                            //if (data.hasOwnProperty("layvalue") && !IsEmpty(data.layvalue) && layvalue.split('|').length > 1) {

                            if (selectdata.hasOwnProperty("layvalue") && !IsEmpty(selectdata.layvalue) && selectdata.layvalue.split('|').length > 1) {
                                inpdom.prop('checked', (value == selectdata.layvalue.split['|'][0]) ? true : false);
                            }
                            else {
                                inpdom.prop('checked', (value == 'true' || value == 'on') ? true : false);
                            }
                            form.render('checkbox', newFormEditor.thisdivid);
                            break;
                        case 'select':
                            inpdom.val(value);
                            form.render('select', newFormEditor.thisdivid);
                            break;
                        default:
                            inpdom.val(value);
                            break;
                    }
                }

            });

            newFormEditor.rightAttributes.defaulttext.text = function () {
                if (newFormEditor.rightAttributes.defaulttext.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "defaulttext": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.defaulttext;
                    }
                }
            }



            //字体大小
            newFormEditor.rightAttributes.textsize.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.textsize.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.textsize.dom.html('<label class="layui-form-label">字体大小</label><div class="layui-input-block"><input name="textsize" class="layui-input" required="" type="text" placeholder="请输入数字" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.textsize.dom.find('input[name^="textsize"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                selectdata.textsize = value;

                if (!IsEmpty(value)) {
                    lbldom.css('font-size', value + "px");
                    lbldom.css('line-height', (Number(value) + 6) + "px");
                }
                else {
                    lbldom.css('font-size', value);
                    lbldom.css('line-height', (value));
                }


                //inpdom.css('width', value);

            });

            newFormEditor.rightAttributes.textsize.text = function () {
                if (newFormEditor.rightAttributes.textsize.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "textsize": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.textsize;
                    }
                }
            }



            //

            /**  <input type="hidden" name="color" value="" id="test-all-input">
                <div id="test-all"></div>
            */
            //字体颜色
            //<div id="div_textcolour"></div>
            newFormEditor.rightAttributes.textcolour.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.textcolour.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.textcolour.dom.html('<label class="layui-form-label">字体颜色</label><div class="layui-input-block"><input type="hidden" name="textcolour" value="" id="textcolour"> </div></div>');
            //添加到元素中

            var div_textcolour = document.createElement("div");
            newFormEditor.rightAttributes.textcolour.dom.find("div").append(div_textcolour);

            //渲染颜色选择事件
            var textcolourcolorpicker = colorpicker.render({
                elem: div_textcolour
                , color: 'rgba(0, 0, 0, 1)'
                , format: 'rgb'
                , predefine: true
                , alpha: true
                , done: function (color) {
                    $('#textcolour').val(color); //向隐藏域赋值
                    color || this.change(color); //清空时执行 change
                    //找到当前选择控件
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }

                    var value = color;
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectdata = domlist[4];
                    var index = domlist[5];
                    selectdata.textcolour = value;
                    //给页面赋值
                    lbldom.css('color', value);
                }
                , change: function (color) {
                    //$('.header-demo,.layui-side .layui-nav').css('background-color', color);
                }
            });



            //注册颜色选择事件
            newFormEditor.rightAttributes.textcolour.text = function () {
                if (newFormEditor.rightAttributes.textcolour.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "textcolour": arguments[0] });
                        //给颜色选择器赋值

                        textcolourcolorpicker.config.color = arguments[0];
                        textcolourcolorpicker.config.that.render();

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.textcolour;
                    }
                }
            }



            //宽度
            newFormEditor.rightAttributes.width.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.width.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.width.dom.html('<label class="layui-form-label">宽度</label><div class="layui-input-block"><input name="width" class="layui-input" required="" type="text" placeholder="请输入数字或百分比" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.width.dom.find('input[name^="width"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                selectdata.width = value;
                inpdivdom.css('width', value);
                //inpdom.css('width', value);

            });

            newFormEditor.rightAttributes.width.text = function () {
                if (newFormEditor.rightAttributes.width.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "width": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.width;
                    }
                }
            }




            //标题宽度
            newFormEditor.rightAttributes.titlewidth.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.titlewidth.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.titlewidth.dom.html('<label class="layui-form-label">标题宽度</label><div class="layui-input-block"><input name="titlewidth" class="layui-input" required="" type="text" placeholder="请输入数字" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.titlewidth.dom.find('input[name^="titlewidth"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                selectdata.titlewidth = value;


                lbldom.css('width', value);

                if (selectdata.layouttype == 'layui-input-block') {
                    if (!IsEmpty(value)) {
                        inpdivdom.css('margin-left', (Number(value) + 30));
                    }
                    else {
                        inpdivdom.css('margin-left', '');
                    }
                }





            });

            newFormEditor.rightAttributes.titlewidth.text = function () {
                if (newFormEditor.rightAttributes.titlewidth.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "titlewidth": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.titlewidth;
                    }
                }
            }



            //是否导出excel  isexportexcel

            newFormEditor.rightAttributes.isexportexcel.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.isexportexcel.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.isexportexcel.dom.html('<label class="layui-form-label">导出Excel</label><div class="layui-input-block"><input name="isexportexcel" type="checkbox" lay-filter="isexportexcel" lay-skin="switch" lay-text="是|否"> </div></div>');
            form.on('switch(isexportexcel)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                var value = this.checked;
                selectdata.isexportexcel = value;
            });
            newFormEditor.rightAttributes.isexportexcel.text = function () {
                if (newFormEditor.rightAttributes.isexportexcel.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "isexportexcel": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.isexportexcel === 'on' ? true : false;
                    }
                }
            };





            //列显示
            newFormEditor.rightAttributes.isdisplaycolumn.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.isdisplaycolumn.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.isdisplaycolumn.dom.html('<label class="layui-form-label">列表显示</label><div class="layui-input-block"><input name="isdisplaycolumn" type="checkbox" lay-filter="isdisplaycolumn" lay-skin="switch" lay-text="显示|隐藏"> </div></div>');
            form.on('switch(isdisplaycolumn)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                var value = this.checked;
                selectdata.isdisplaycolumn = value;
            });
            newFormEditor.rightAttributes.isdisplaycolumn.text = function () {
                if (newFormEditor.rightAttributes.isdisplaycolumn.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "isdisplaycolumn": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.isdisplaycolumn === 'on' ? true : false;
                    }
                }
            };






            //只读
            newFormEditor.rightAttributes.isreadonly.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.isreadonly.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.isreadonly.dom.html('<label class="layui-form-label">只读</label><div class="layui-input-block"><input name="isreadonly" type="checkbox" lay-filter="isreadonly" lay-skin="switch" lay-text="只读|可写"> </div></div>');
            form.on('switch(isreadonly)', function (data) {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                var value = this.checked;
                selectdata.isreadonly = value;




            });
            newFormEditor.rightAttributes.isreadonly.text = function () {
                if (newFormEditor.rightAttributes.isreadonly.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "isreadonly": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.isreadonly === 'on' ? true : false;
                    }
                }
            };



            //seehide 查看隐藏

            newFormEditor.rightAttributes.seehide.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.seehide.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.seehide.dom.html('<label class="layui-form-label">查看隐藏</label><div class="layui-input-block"><input name="seehide" type="checkbox" lay-filter="seehide" lay-skin="switch" lay-text="隐藏|显示"> </div></div>');
            form.on('switch(seehide)', function (data) {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                var value = this.checked;
                selectdata.seehide = value;




            });

            newFormEditor.rightAttributes.seehide.text = function () {
                if (newFormEditor.rightAttributes.seehide.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "seehide": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.seehide === 'on' ? true : false;
                    }
                }
            };








            //列表合计totalrow

            newFormEditor.rightAttributes.totalrow.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.totalrow.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.totalrow.dom.html('<label class="layui-form-label">列表合计</label><div class="layui-input-block"><input name="totalrow" type="checkbox" lay-filter="totalrow" lay-skin="switch" lay-text="开启|关闭"> </div></div>');
            form.on('switch(totalrow)', function (data) {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                var value = this.checked;
                selectdata.totalrow = value;




            });
            newFormEditor.rightAttributes.totalrow.text = function () {
                if (newFormEditor.rightAttributes.totalrow.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "totalrow": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.totalrow === 'on' ? true : false;
                    }
                }
            };




            //isowndefinition 下拉框是否自定义数据

            newFormEditor.rightAttributes.isowndefinition.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.isowndefinition.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.isowndefinition.dom.html('<label class="layui-form-label">自定义值</label><div class="layui-input-block"><input name="isowndefinition" type="checkbox" lay-filter="isowndefinition" lay-skin="switch" lay-text="开启|关闭"> </div></div>');
            form.on('switch(isowndefinition)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                var value = this.checked;
                selectdata.isowndefinition = value;




            });
            newFormEditor.rightAttributes.isowndefinition.text = function () {
                if (newFormEditor.rightAttributes.isowndefinition.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "isowndefinition": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.isowndefinition === 'on' ? true : false;
                    }
                }
            };







            //隐藏
            newFormEditor.rightAttributes.display.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.display.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.display.dom.html('<label class="layui-form-label">隐藏</label><div class="layui-input-block"><input name="display" type="checkbox" lay-filter="display" lay-skin="switch" lay-text="隐藏|显示"> </div></div>');
            form.on('switch(display)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                var value = this.checked;
                selectdata.display = value;




            });
            newFormEditor.rightAttributes.display.text = function () {
                if (newFormEditor.rightAttributes.display.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "display": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.display === 'on' ? true : false;
                    }
                }
            };



            //必填 required
            newFormEditor.rightAttributes.required.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.required.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.required.dom.html('<label class="layui-form-label">必填</label><div class="layui-input-block"><input name="required" type="checkbox" lay-filter="required" lay-skin="switch" lay-text="必填|可选"> </div></div>');
            form.on('switch(required)', function (data) {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = this.checked ? 'required' : '';
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                var verify = inpdom.attr("lay-verify");


                if (!IsEmpty(verify)) {
                    if (value === 'required') {
                        if (verify.indexOf('required') < 0) {
                            //赋值
                            verify = 'required|' + verify;
                            inpdom.attr("lay-verify", verify);
                        }
                        else {
                            //已经存在 不需要在操作
                        }

                    }
                    else {
                        //删除
                        if (verify.indexOf('required|') > -1) {

                            inpdom.attr("lay-verify", verify.replace(new RegExp("required|", "g"), ''));
                        }
                        else if (verify.indexOf('required') > -1) {

                            inpdom.attr("lay-verify", verify.replace(new RegExp("required", "g"), ''));
                        }
                    }
                }
                else {
                    inpdom.attr("lay-verify", value);
                }

                selectdata.required = this.checked;




            });

            newFormEditor.rightAttributes.required.text = function () {
                if (newFormEditor.rightAttributes.required.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "required": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.required === 'on' ? true : false;
                    }
                }
            };

            //校验layverify

            newFormEditor.rightAttributes.layverify.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.layverify.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.layverify.dom.html('<label class="layui-form-label">校验</label><div class="layui-input-block"><select name="layverify" lay-filter="layverify"><option value="">默认</option><option value="phone">手机号</option><option value="email">邮箱</option><option value="url">网址</option><option value="number">数字</option><option value="date">日期</option><option value="identity">身份证</option></select></div ></div > ');

            form.on('select(layverify)', function (data) {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                var verify = inpdom.attr("lay-verify");

                if (!IsEmpty(data.value)) {
                    if (!IsEmpty(verify) && verify.indexOf('required') > -1) {

                        inpdom.attr("lay-verify", 'required|' + data.value);
                    }
                    else {
                        inpdom.attr("lay-verify", data.value);
                    }
                }
                else {
                    if (!IsEmpty(verify) && verify.indexOf('required') > -1) {

                        inpdom.attr("lay-verify", 'required');
                    }
                    else {
                        inpdom.attr("lay-verify", '');
                    }
                }

                selectdata.layverify = data.value;




            });
            newFormEditor.rightAttributes.layverify.text = function () {
                if (newFormEditor.rightAttributes.layverify.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "layverify": arguments[0] });

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.layverify;
                    }
                }
            };






            //高度
            newFormEditor.rightAttributes.height.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.height.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.height.dom.html('<label class="layui-form-label">高度</label><div class="layui-input-block"><input name="height" class="layui-input" required="" type="text" placeholder="请输入数字或百分比" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.height.dom.find('input[name^="height"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                selectdata.height = value;
                inpdom.css('height', value);

            });

            newFormEditor.rightAttributes.height.text = function () {
                if (newFormEditor.rightAttributes.height.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "height": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.height;
                    }
                }
            }


            //辅助文字wordaux
            newFormEditor.rightAttributes.wordaux.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.wordaux.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.wordaux.dom.html('<label class="layui-form-label">辅助文字</label><div class="layui-input-block"><input name="wordaux" class="layui-input" required="" type="text" placeholder="请输入辅助文字" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.wordaux.dom.find('input[name^="wordaux"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                if (value.length > 0) {
                    //增加了行内元素 样式不动
                    //divdom.removeClass();
                    //divdom.addClass("layui-input-inline");

                    var wordaux = divdom.find('div[class^="layui-form-mid layui-word-aux"]');
                    if (wordaux.length > 0) {
                        wordaux.html(value);
                    }
                    else {
                        divdom.append('<div class="layui-form-mid layui-word-aux">' + value + '</div>');
                    }


                }
                else {
                    //增加了行内元素 样式不动
                    //divdom.removeClass();
                    //divdom.addClass("layui-input-block");
                    var wordaux = divdom.find('div[class^="layui-form-mid layui-word-aux"]');
                    if (wordaux.length > 0) {
                        wordaux.remove();
                    }
                }
                selectdata.wordaux = value;

            });

            //取值 赋值方法
            newFormEditor.rightAttributes.wordaux.text = function () {
                if (newFormEditor.rightAttributes.wordaux.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "wordaux": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.wordaux;
                    }
                }
            }


            //layReqtext 必填提示
            newFormEditor.rightAttributes.layReqtext.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.layReqtext.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.layReqtext.dom.html('<label class="layui-form-label">必填提示</label><div class="layui-input-block"><input name="layReqtext" class="layui-input" required="" type="text" placeholder="请输入必填提示" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.layReqtext.dom.find('input[name^="layReqtext"]').on('input ' + oneventname, function () {


                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];



                selectdata.layReqtext = value;

                inpdom.attr("lay-reqtext", value)

            });

            newFormEditor.rightAttributes.layReqtext.text = function () {
                if (newFormEditor.rightAttributes.layReqtext.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "layReqtext": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.layReqtext;
                    }
                }
            }

            //iscolumnvalue 列表显示text还是value

            newFormEditor.rightAttributes.iscolumnvalue.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.iscolumnvalue.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.iscolumnvalue.dom.html('<label class="layui-form-label">列表值类型</label><div class="layui-input-block"><input name="iscolumnvalue" type="checkbox" lay-filter="iscolumnvalue" lay-skin="switch" lay-text="隐藏值|显示值"> </div></div>');
            form.on('switch(iscolumnvalue)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                var value = this.checked;
                selectdata.iscolumnvalue = value;




            });
            newFormEditor.rightAttributes.iscolumnvalue.text = function () {
                if (newFormEditor.rightAttributes.iscolumnvalue.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "iscolumnvalue": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.iscolumnvalue === 'on' ? true : false;
                    }
                }
            };












            //布局类型layouttype
            newFormEditor.rightAttributes.layouttype.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.layouttype.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.layouttype.dom.html('<label class="layui-form-label">布局类型</label><div class="layui-input-block"><select name="layouttype" lay-filter="layouttype"><option value="layui-input-block">行元素</option><option value="layui-input-inline">行内元素</option></select></div ></div > ');

            form.on('select(layouttype)', function (data) {



                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                if (selectdata.layouttype == 'layui-input-block') {
                    inpdivdom.css('margin-left', '');
                }
                else if (!IsEmpty(selectdata.titlewidth)) {
                    inpdivdom.css('margin-left', (Number(selectdata.titlewidth) + 30));
                }

                inpdivdom.removeClass();
                inpdivdom.addClass(data.value);
                selectdata.layouttype = data.value;


               




            });
            newFormEditor.rightAttributes.layouttype.text = function () {
                if (newFormEditor.rightAttributes.layouttype.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "layouttype": arguments[0] });

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.layouttype;
                    }
                }
            };




            //生成开关内容
            newFormEditor.rightAttributes.laytext.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.laytext.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.laytext.dom.html('<label class="layui-form-label">开关内容</label><div class="layui-input-block"><input name="laytext" class="layui-input" required="" type="text" laytext="请输入“开|关”格式" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.laytext.dom.find('input[name^="laytext"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                selectdata.laytext = value;
                inpdom.attr("lay-text", value)
                //渲染
                //form.render('checkbox', newFormEditor.thisdivid)


            });

            newFormEditor.rightAttributes.laytext.text = function () {
                if (newFormEditor.rightAttributes.laytext.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "laytext": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.laytext;
                    }
                }
            }

            //layvalue 开关隐藏值


            newFormEditor.rightAttributes.layvalue.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.layvalue.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.layvalue.dom.html('<label class="layui-form-label">隐藏值</label><div class="layui-input-block"><input name="layvalue" class="layui-input" required="" type="text" laytext="请输入“开|关”格式" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.layvalue.dom.find('input[name^="layvalue"]').on('input ' + oneventname, function () {

                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                selectdata.layvalue = value;
                //inpdom.attr("lay-text", value)
                //渲染
                //form.render('checkbox', newFormEditor.thisdivid)


            });

            newFormEditor.rightAttributes.layvalue.text = function () {
                if (newFormEditor.rightAttributes.layvalue.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "layvalue": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.layvalue;
                    }
                }
            }






            //日期类型datetype

            newFormEditor.rightAttributes.datetype.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.datetype.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.datetype.dom.html('<label class="layui-form-label">日期类型</label><div class="layui-input-block"><select name="datetype" lay-filter="datetype"><option value="year">年</option><option value="month">年月</option><option value="time">时间</option><option value="date">日期</option><option value="datetime">日期时间</option></select></div ></div > ');

            form.on('select(datetype)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }

                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.datetype = data.value;

            });

            newFormEditor.rightAttributes.datetype.text = function () {
                if (newFormEditor.rightAttributes.datetype.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "datetype": arguments[0] });

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.datetype;
                    }
                }
            };



            //日期格式dateformat
            newFormEditor.rightAttributes.dateformat.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.dateformat.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.dateformat.dom.html('<label class="layui-form-label">日期格式</label><div class="layui-input-block"><input name="dateformat" class="layui-input" required="" type="text" placeholder="请输入yyyy-MM-dd HH:mm:ss格式" value="" autocomplete="off" lay-verify="required"> </div></div>');
            //文本框输入事件
            newFormEditor.rightAttributes.dateformat.dom.find('input[name^="dateformat"]').on('input ' + oneventname, function () {


                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var value = $(this).val();
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];


                selectdata.dateformat = value;
                //渲染



            });

            newFormEditor.rightAttributes.dateformat.text = function () {
                if (newFormEditor.rightAttributes.dateformat.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "dateformat": arguments[0] });
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.dateformat;
                    }
                }
            }

            //时间是否为范围选择器daterange
            newFormEditor.rightAttributes.daterange.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.daterange.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.daterange.dom.html('<label class="layui-form-label">选择范围</label><div class="layui-input-block"><input name="daterange" type="checkbox" lay-filter="daterange" lay-skin="switch" lay-text="是|否"> </div></div>');
            form.on('switch(daterange)', function (data) {

                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                var value = this.checked;
                selectdata.daterange = value;



            });
            newFormEditor.rightAttributes.daterange.text = function () {
                if (newFormEditor.rightAttributes.daterange.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        if (arguments[0] === true || arguments[0] === false) {
                            form.val('form-attr', { "daterange": arguments[0] });
                        }
                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.daterange === 'on' ? true : false;
                    }
                }
            };


            //ajax获取字典类型

            //var dictClassListHtml = '<option value="UserInfo">人员选择</option>';
            var dictClassListHtml = '';
            for (var i in dictClassList) {
                dictClassListHtml += '<option value="' + dictClassList[i].sysDictClassCode + '">' + dictClassList[i].sysDictClassName + '</option>';
            }

            //绑定字典dictclass
            newFormEditor.rightAttributes.dictclass.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.dictclass.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.dictclass.dom.html('<label class="layui-form-label">字典类型</label><div class="layui-input-block"><select name="dictclass" lay-filter="dictclass"><option value="">请选择</option>' + dictClassListHtml + '</select></div ></div > ');
            form.on('select(dictclass)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];
                selectdata.dictclass = data.value;
            });
            newFormEditor.rightAttributes.dictclass.text = function () {
                if (newFormEditor.rightAttributes.dictclass.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "dictclass": arguments[0] });

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.dictclass;
                    }
                }
            };



            //选项 options
            var tableoptionsdom = document.createElement("table");
            $(tableoptionsdom).attr('id', 'options');
            $(tableoptionsdom).attr('lay-filter', 'options');

            newFormEditor.rightAttributes.options.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.options.dom.addClass('layui-form-item');
            //this.rightAttributes.options.dom.html('<table id="options" lay-filter="options"></table>');
            newFormEditor.rightAttributes.options.dom.html(tableoptionsdom);
            //渲染表格
            var tableoptions = table.render({
                elem: tableoptionsdom,
                toolbar: '<div class="layui-btn-container"> <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" lay-event="add"><i class="layui-icon">&#xe654;</i></button> </div>',
                defaultToolbar: [],
                data: [],
                limit: 500
                , cols: [[ //表头 
                    { field: 'text', title: '显示值', unresize: true, width: 90, edit: 'text' }
                    , { field: 'value', title: '隐藏值', unresize: true, edit: 'text', width: 90 }
                    , { fixed: 'right', title: '', unresize: true, width: 70, toolbar: '<div><button class="layui-btn layui-btn-danger layui-btn-sm" type="button" lay-event="del"><i class="layui-icon">&#xe640;</i></button></div>' }
                ]]
            });

            //创建取值 赋值 参数
            newFormEditor.rightAttributes.options.text = function () {
                if (tableoptionsdom !== null) {


                    if (arguments.length > 0) {
                        //赋值
                        if (!IsEmpty(arguments[0]) && (arguments[0].length > 1 || (arguments[0].length == 1 && !IsEmpty(arguments[0][0])))) {
                            tableoptions.reload({ data: arguments[0] });
                        }
                        else {
                            tableoptions.reload({ data: [] });
                        }
                    }
                    else {
                        //取值
                        var tabledata = [];
                        for (var i in table.cache['options']) {
                            if (!IsEmpty(table.cache['options'][i]) && table.cache['options'][i].hasOwnProperty("text") && table.cache['options'][i].hasOwnProperty("value") && table.cache['options'][i].hasOwnProperty("index")) {
                                tabledata.push({ text: table.cache['options'][i].text, value: table.cache['options'][i].value, index: table.cache['options'][i].index });
                            }
                        }
                        return tabledata;
                    }
                }
            };

            //监听行工具事件 删除
            table.on('tool(options)', function (obj) {
                var data = obj.data;
                //console.log(obj)
                if (obj.event === 'del') {
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];

                    switch (selectData.tag) {
                        case 'select':
                            //删除对应数据结构
                            inpdom[0].options.remove(data.index);
                            form.render('select', newFormEditor.thisdivid)
                            break;
                        case 'checkbox':
                            $(inpdom[data.index]).remove();
                            inpdivdom.find('div').remove();
                            form.render('checkbox', newFormEditor.thisdivid)

                            break;
                        case 'radio':
                            $(inpdom[data.index]).remove();
                            inpdivdom.find('div').remove();
                            form.render('radio', newFormEditor.thisdivid)
                            break;
                        default:
                            break;
                    }

                    //删除属性表格数据
                    obj.del();

                    //获取表格数据
                    var optionsdata = newFormEditor.rightAttributes.options.text();
                    //重新排序
                    for (var i in optionsdata) {
                        optionsdata[i].index = i;
                    }

                    //放入数据
                    selectData.options = optionsdata;
                    //渲染表格
                    tableoptions.reload({ data: selectData.options });
                }
            });
            //头工具栏事件
            table.on('toolbar(options)', function (obj) {
                if (obj.event === 'add') {
                    //搜索dom
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];

                    //获取数据
                    var tabledata = newFormEditor.rightAttributes.options.text();

                    tabledata.push({ text: "", value: "", index: tabledata.length });

                    tableoptions.reload({ data: tabledata });
                    //添加到对应数据里面去

                    switch (selectData.tag) {
                        case 'select':
                            inpdom.append("<option value=''></option>");
                            form.render('select', newFormEditor.thisdivid)
                            break;
                        case 'checkbox':
                            inpdivdom.append("<input name='" + selectData.id + "' disabled title='' type='checkbox' value=''></input>");
                            form.render('checkbox', newFormEditor.thisdivid)
                            break;
                        case 'radio':
                            inpdivdom.append("<input name='" + selectData.id + "' disabled title='' type='radio' value=''></input>");
                            form.render('radio', newFormEditor.thisdivid)
                            break;
                        default:
                            break;
                    }
                    selectData.options = tabledata;

                    //滚动到最下面
                    //$('#right_Attributes_Content').scrollTop($('#right_Attributes_Content')[0].scrollHeight);

                }
            });
            //注册修改数据事件
            table.on('edit(options)', function (obj) { //注：edit是固定事件名，test是table原始容器的属性 lay-filter="对应的值"
                //console.log(obj.value); //得到修改后的值
                //console.log(obj.field); //当前编辑的字段名
                //console.log(obj.data); //所在行的所有相关数据  
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }

                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];

                switch (selectData.tag) {
                    case 'select':
                        if (obj.field === 'text') {
                            $(inpdom[0].options[obj.data.index]).html(obj.value);
                        }
                        else {
                            $(inpdom[0].options[obj.data.index]).attr('value', obj.value);
                        }
                        //渲染数据
                        form.render('select', newFormEditor.thisdivid)
                        break;
                    case 'checkbox':
                        if (obj.field === 'text') {
                            $(inpdom[obj.data.index]).attr('title', obj.value);
                        }
                        else {
                            $(inpdom[obj.data.index]).attr('value', obj.value);
                        }
                        form.render('checkbox', newFormEditor.thisdivid)
                        break;
                    case 'radio':
                        if (obj.field === 'text') {
                            $(inpdom[obj.data.index]).attr('title', obj.value);
                        }
                        else {
                            $(inpdom[obj.data.index]).attr('value', obj.value);
                        }

                        form.render('radio', newFormEditor.thisdivid)
                        break;
                    default:
                        break;
                }
                //修改数据集合
                selectData.options[obj.data.index][obj.field] = obj.value;

            });


            //合计到totaltocontrol

            var tabletotaltocontroldom = document.createElement("table");
            $(tabletotaltocontroldom).attr('id', 'totaltocontrols');
            $(tabletotaltocontroldom).attr('lay-filter', 'totaltocontrols');
            newFormEditor.rightAttributes.totaltocontrols.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.totaltocontrols.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.totaltocontrols.dom.html(tabletotaltocontroldom);

            /**
             * 生成合计用户控件
             * @param {any} key
             */

            function GetTaltoControl(key) {
                var putjson = newFormEditor.putjson;
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];

                function GetControlOptins(conjson, selectedID) {
                    var html1 = "";
                    //判断页面是否存在控件
                    if (Auxiliary.IsEmpty(conjson)) {
                        return null;
                    }
                    for (var i in conjson) {
                        if (conjson[i].tag == "input" && selectData.id != conjson[i].id) {
                            html1 += "<option value='" + conjson[i].id + "' ";
                            if (conjson[i].id == selectedID) {
                                html1 += " selected ";
                            }
                            html1 += ">";
                            html1 += conjson[i].title + "</option> ";
                        }

                        if (conjson[i].tag == "row" && !IsEmpty(conjson[i].controls)) {
                            html1 += GetControlOptins(conjson[i].controls, selectedID);
                        }
                    }

                    return html1;

                }
                //生成html
                var html = "<select lay-verify='required'  lay-filter='totaltocontroltable' lay-search=''> <option value=''>请选择</option> ";
                if (!Auxiliary.IsEmpty(putjson)) {
                    html += GetControlOptins(putjson, key);
                }

                return html;

            }





            var tabletotaltocontrol = table.render({
                elem: tabletotaltocontroldom,
                toolbar: '<div class="layui-btn-container"> <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" lay-event="add"><i class="layui-icon">&#xe654;</i></button> </div>',
                defaultToolbar: [],
                data: [],
                limit: 500
                , cols: [[ //表头 
                    {
                        field: 'text', title: '合计到', unresize: true, width: 260, templet: function (d) {
                            return GetTaltoControl(d.text);
                        }
                    }
                    , { title: '', unresize: true, width: 60, toolbar: '<div><button class="layui-btn layui-btn-danger layui-btn-sm" type="button" lay-event="del"><i class="layui-icon">&#xe640;</i></button></div>' }
                ]]
            });




            //创建取值 赋值 参数
            newFormEditor.rightAttributes.totaltocontrols.text = function () {
                if (tabletotaltocontrol !== null) {
                    if (arguments.length > 0) {
                        //赋值之前，初始化下拉框数据

                        //赋值
                        if (!IsEmpty(arguments[0]) && (arguments[0].length > 1 || (arguments[0].length == 1 && !IsEmpty(arguments[0][0])))) {
                            tabletotaltocontrol.reload({ data: arguments[0] });
                        }
                        else {
                            tabletotaltocontrol.reload({ data: [] });
                        }
                    }
                    else {
                        //取值
                        var tabledata = [];
                        for (var i in table.cache['totaltocontrols']) {
                            if (!IsEmpty(table.cache['totaltocontrols'][i]) && table.cache['totaltocontrols'][i].hasOwnProperty("text") && table.cache['totaltocontrols'][i].hasOwnProperty("index")) {
                                tabledata.push({ text: table.cache['totaltocontrols'][i].text, index: table.cache['totaltocontrols'][i].index });
                            }
                        }
                        return tabledata;
                    }
                }
            };

            //监听行工具事件 删除
            table.on('tool(totaltocontrols)', function (obj) {
                var data = obj.data;
                //console.log(obj)
                if (obj.event === 'del') {
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];




                    //删除属性表格数据
                    obj.del();

                    //获取表格数据
                    var totaltocontrols = selectData.totaltocontrols;
                    totaltocontrols.splice(obj.data.index, 1);

                    //重新排序
                    for (var i in totaltocontrols) {
                        totaltocontrols[i].index = i;
                    }

                    //放入数据
                    selectData.totaltocontrols = totaltocontrols;
                    //渲染表格
                    tabletotaltocontrol.reload({ data: selectData.totaltocontrols });
                }
            });




            //头工具栏事件
            table.on('toolbar(totaltocontrols)', function (obj) {
                if (obj.event === 'add') {
                    //搜索dom
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];

                    //获取数据
                    //var tabledata = newFormEditor.rightAttributes.totaltocontrols.text();


                    var tabledata = selectData.totaltocontrols;
                    if (IsEmpty(tabledata)) {
                        tabledata = [];
                    }
                    tabledata.push({ text: "", index: tabledata.length });

                    tabletotaltocontrol.reload({ data: tabledata });

                    selectData.totaltocontrols = tabledata;

                    //滚动到最下面
                    //$('#right_Attributes_Content').scrollTop($('#right_Attributes_Content')[0].scrollHeight);

                }
            });


            //修改 totaltocontroltable


            form.on('select(totaltocontroltable)', function (data) {

                //取当前选择的数据
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];


                //获取当前行tr对象
                var elem = data.othis.parents('tr');
                //data-index
                selectData.totaltocontrols[$(elem).attr("data-index")].text = data.value;
                selectData.totaltocontrols[$(elem).attr("data-index")].index = $(elem).attr("data-index");

            })





            //totalproportion 选择比例
            var tabletotalproportiondom = document.createElement("table");
            $(tabletotalproportiondom).attr('id', 'totalproportion');
            $(tabletotalproportiondom).attr('lay-filter', 'totalproportion');

            newFormEditor.rightAttributes.totalproportion.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.totalproportion.dom.addClass('layui-form-item');
       

            newFormEditor.rightAttributes.totalproportion.dom.html(tabletotalproportiondom);


            var tabletotalproportion = table.render({
                elem: tabletotalproportiondom,
                toolbar: '<div class="layui-btn-container"> <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" lay-event="add"><i class="layui-icon">&#xe654;</i></button> </div>',
                defaultToolbar: [],
                data: [],
                limit: 500,
               // width:500, 
                cols: [[ //表头 
                    {
                        field: 'proportionsource', title: '比例源', width: 95, templet: function (d) {
                            return GetTaltoSourceControl(d.proportionsource);
                        }

                    },
                    {
                        field: 'proportionto', title: '比例到', width: 95, templet: function (d) {
                            return GetTaltoBiLiControl(d.proportionto);
                        }
                    }
                    ,
                    
                    {
                        field: 'percentsign', title: '后缀%', width: 80, templet: function (d) {

                            return '<input type="checkbox" name="chepercentsign"  title="%" lay-filter="laychepercentsign" ' + ((d.percentsign === true || d.percentsign === 'true'  || d.percentsign === 'on') ?'checked':'')+ '>'
                        }
                    }
                    
                    ,
                    { title: '', unresize: true, width: 60, toolbar: '<div><button class="layui-btn layui-btn-danger layui-btn-sm" type="button" lay-event="del"><i class="layui-icon">&#xe640;</i></button></div>' }
                ]]
            });


            //查找比例到当前页面的数据
            /**
             * 生成比例来源控件
             * @param {any} key
            */
            function GetTaltoSourceControl(key) {
                var putjson = newFormEditor.putjson;
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];

                function GetControlOptins(conjson, selectedID) {
                    var html1 = "";
                    //判断页面是否存在控件
                    if (IsEmpty(conjson) || IsEmpty(conjson[0])) {
                        return null;
                    }
                    for (var i in conjson) {
                        if (conjson[i].tag == "input" && selectData.id != conjson[i].id) {
                            //判断是否有合计到本控件来源控件
                            if (conjson[i].hasOwnProperty("totaltocontrols") && !IsEmpty(conjson[i].totaltocontrols) && conjson[i].totaltocontrols.length > 0 && !IsEmpty(conjson[i].totaltocontrols[0])) {

                                for (var s in conjson[i].totaltocontrols) {
                                    if (!IsEmpty(conjson[i].totaltocontrols[s]) && conjson[i].totaltocontrols[s].hasOwnProperty("text") && conjson[i].totaltocontrols[s].text == selectData.id) {
                                        //查找到来源添加数据
                                        html1 += "<option value='" + conjson[i].id + "' ";
                                        if (conjson[i].id == selectedID) {
                                            html1 += " selected ";
                                        }
                                        html1 += ">";
                                        html1 += conjson[i].title + "</option> ";

                                        break;
                                    }
                                }
                            }
                        }

                        if (conjson[i].tag == "row" && !IsEmpty(conjson[i].controls)) {
                            html1 += GetControlOptins(conjson[i].controls, selectedID);
                        }
                    }

                    return html1;

                }
                //生成html
                var html = "<select lay-verify='required'  lay-filter='selectproportionsource' lay-search=''> <option value=''>请选择</option> ";
                if (!Auxiliary.IsEmpty(putjson)) {
                    html += GetControlOptins(putjson, key);
                }


                return html;

            }


            function GetTaltoBiLiControl(key) {
                var putjson = newFormEditor.putjson;
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];

                function GetControlOptins(conjson, selectedID) {
                    var html1 = "";
                    //判断页面是否存在控件
                    if (Auxiliary.IsEmpty(conjson)) {
                        return null;
                    }
                    for (var i in conjson) {
                        if (conjson[i].tag == "input" && selectData.id != conjson[i].id) {
                            html1 += "<option value='" + conjson[i].id + "' ";
                            if (conjson[i].id == selectedID) {
                                html1 += " selected ";
                            }
                            html1 += ">";
                            html1 += conjson[i].title + "</option> ";
                        }

                        if (conjson[i].tag == "row" && !IsEmpty(conjson[i].controls)) {
                            html1 += GetControlOptins(conjson[i].controls, selectedID);
                        }
                    }

                    return html1;

                }
                //生成html
                var html = "<select lay-verify='required'  lay-filter='selectproportionto' lay-search=''> <option value=''>请选择</option> ";
                if (!Auxiliary.IsEmpty(putjson)) {
                    html += GetControlOptins(putjson, key);
                }


                return html;

            }



            //创建取值 赋值 参数
            newFormEditor.rightAttributes.totalproportion.text = function () {
                if (tabletotalproportion !== null) {
                    if (arguments.length > 0) {
                        //赋值之前，初始化下拉框数据

                        //赋值
                        if (!IsEmpty(arguments[0]) && (arguments[0].length > 1 || (arguments[0].length == 1 && !IsEmpty(arguments[0][0])))) {
                            tabletotalproportion.reload({ data: arguments[0] });
                        }
                        else {
                            tabletotalproportion.reload({ data: [] });
                        }

                    }
                    else {
                        //取值
                        var tabledata = [];
                        for (var i in table.cache['totalproportion']) {
                            if (!IsEmpty(table.cache['totalproportion'][i]) &&
                                table.cache['totalproportion'][i].hasOwnProperty("proportionsource") &&
                                table.cache['totalproportion'][i].hasOwnProperty("proportionto") &&
                                table.cache['totalproportion'][i].hasOwnProperty("index")) {
                                tabledata.push({
                                    proportionsource: table.cache['totalproportion'][i].proportionsource,
                                    proportionto: table.cache['totalproportion'][i].proportionto,
                                    percentsign: table.cache['totalproportion'][i].percentsign,
                                    index: table.cache['totalproportion'][i].index
                                });
                            }
                        }
                        return tabledata;
                    }
                }
            };




            //监听行工具事件 删除
            table.on('tool(totalproportion)', function (obj) {
                var data = obj.data;
                //console.log(obj)
                if (obj.event === 'del') {
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];




                    //删除属性表格数据
                    obj.del();

                    //获取表格数据
                    var totalproportion = selectData.totalproportion;
                    totalproportion.splice(obj.data.index, 1);

                    //重新排序
                    for (var i in totalproportion) {
                        totalproportion[i].index = i;
                    }

                    //放入数据
                    selectData.totalproportion = totalproportion;
                    //渲染表格
                    tabletotalproportion.reload({ data: selectData.totalproportion });
                }
            });




            //头工具栏事件
            table.on('toolbar(totalproportion)', function (obj) {
                if (obj.event === 'add') {
                    //搜索dom
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];

                    //获取数据
                    //var tabledata = newFormEditor.rightAttributes.totaltocontrols.text();


                    var tabledata = selectData.totalproportion;
                    if (IsEmpty(tabledata)) {
                        tabledata = [];
                    }
                    tabledata.push({ proportionsource: "", proportionto: "", percentsign:"", index: tabledata.length });

                    tabletotalproportion.reload({ data: tabledata });

                    selectData.totalproportion = tabledata;

                    //滚动到最下面
                    //$('#right_Attributes_Content').scrollTop($('#right_Attributes_Content')[0].scrollHeight);

                }
            });

            //selectproportionsource

            //selectproportionto

            //后缀
            form.on('checkbox(laychepercentsign)', function (data) {
                

                //取当前选择的数据
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];


                //获取当前行tr对象
                var elem = data.othis.parents('tr');
                //data-index
                selectData.totalproportion[$(elem).attr("data-index")].percentsign = data.elem.checked;

                selectData.totalproportion[$(elem).attr("data-index")].index = $(elem).attr("data-index");





            });

            //比例源
            form.on('select(selectproportionsource)', function (data) {

                //取当前选择的数据
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];


                //获取当前行tr对象
                var elem = data.othis.parents('tr');
                //data-index
                selectData.totalproportion[$(elem).attr("data-index")].proportionsource = data.value;

                selectData.totalproportion[$(elem).attr("data-index")].index = $(elem).attr("data-index");

            })

            //比例到
            form.on('select(selectproportionto)', function (data) {

                //取当前选择的数据
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];


                //获取当前行tr对象
                var elem = data.othis.parents('tr');
                //data-index
                selectData.totalproportion[$(elem).attr("data-index")].proportionto = data.value;

                selectData.totalproportion[$(elem).attr("data-index")].index = $(elem).attr("data-index");

            })



            //联动事件

            //linkage 联动事件
            var tablelinkagedom = document.createElement("table");
            $(tablelinkagedom).attr('id', 'linkage');
            $(tablelinkagedom).attr('lay-filter', 'linkage');

            newFormEditor.rightAttributes.linkage.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.linkage.dom.addClass('layui-form-item');


            newFormEditor.rightAttributes.linkage.dom.html(tablelinkagedom);


            var tablelinkage = table.render({
                elem: tablelinkagedom,
                toolbar: '<div class="layui-btn-container"> <button class="layui-btn layui-btn-normal layui-btn-sm" type="button" lay-event="add"><i class="layui-icon">&#xe654;</i></button> </div>',
                defaultToolbar: [],
                data: [],
                limit: 500,
                // width:500, 
                cols: [[ //表头 

                    /*
                    {
                        field: 'condition', title: '条件', width: 95, templet: function (d) {
                            return '<input type="checkbox" name="condition" lay-skin="switch"  lay-text="开启|关闭" lay-filter="laycondition" ' + ((d.condition === true || d.condition === 'true' || d.condition === 'on') ? 'checked' : '') + '>'
                        }

                    },
                    */
                    {
                        field: 'condition', title: '条件', unresize: true, width: 90, templet: function (d) {
                            return d.condition.text;
                        }
                    },

                   


                    {
                        field: 'linkagecontrol', title: '控件', width: 95, templet: function (d) {

                            var key = d.linkagecontrol;

                                var putjson = newFormEditor.putjson;
                                var domlist = getDivAndInpAndLblDom();
                                if (domlist === null) {
                                    return;
                                }
                                var divdom = domlist[0];
                                var inpdivdom = domlist[1];
                                var inpdom = domlist[2];
                                var lbldom = domlist[3];
                                var selectData = domlist[4];

                                function GetControlOptins(conjson, selectedID) {
                                    var html1 = "";
                                    //判断页面是否存在控件
                                    if (Auxiliary.IsEmpty(conjson)) {
                                        return null;
                                    }
                                    for (var i in conjson) {
                                        if (selectData.id != conjson[i].id) {
                                            html1 += "<option value='" + conjson[i].id + "' ";
                                            if (conjson[i].id == selectedID) {
                                                html1 += " selected ";
                                            }
                                            html1 += ">";
                                            html1 += conjson[i].title + "</option> ";
                                        }

                                        if (conjson[i].tag == "row" && !IsEmpty(conjson[i].controls)) {
                                            html1 += GetControlOptins(conjson[i].controls, selectedID);
                                        }
                                    }

                                    return html1;

                                }
                                //生成html
                            var html = "<select lay-verify='required'  lay-filter='selectlinkagecontrol' lay-search=''> <option value=''>请选择</option> ";
                                if (!Auxiliary.IsEmpty(putjson)) {
                                    html += GetControlOptins(putjson, key);
                                }
                                return html;
                        }
                    }
                    ,

                    {
                        field: 'linkageevent', title: '事件', width: 80, templet: function (d) {

                            var html = "<select lay-verify='required'  lay-filter='selectlinkageevent' lay-search=''> <option value=''>请选择</option> ";

                            html += "<option value='hide' " + (d.linkageevent === 'hide' ?"selected":"")+" >隐藏</option>"
                            html += "<option value='display' " + (d.linkageevent === 'display' ? "selected" : "") +" >显示</option>";
                            return html;
                        }
                    }

                    ,
                    { title: '', unresize: true, width: 60, toolbar: '<div><button class="layui-btn layui-btn-danger layui-btn-sm" type="button" lay-event="del"><i class="layui-icon">&#xe640;</i></button></div>' }
                ]]
            });


            //创建取值 赋值 参数
            newFormEditor.rightAttributes.linkage.text = function () {
                if (tablelinkage !== null) {
                    if (arguments.length > 0) {
                        //赋值之前，初始化下拉框数据

                        //赋值
                        if (!IsEmpty(arguments[0]) && (arguments[0].length > 1 || (arguments[0].length == 1 && !IsEmpty(arguments[0][0])))) {
                            tablelinkage.reload({ data: arguments[0] });
                        }
                        else {
                            tablelinkage.reload({ data: [] });
                        }

                    }
                    else {
                        //取值
                        var tabledata = [];
                        for (var i in table.cache['linkage']) {
                            if (!IsEmpty(table.cache['linkage'][i]) && table.cache['linkage'][i].hasOwnProperty("condition") && table.cache['linkage'][i].hasOwnProperty("linkagecontrol") && table.cache['linkage'][i].hasOwnProperty("linkageevent") && table.cache['linkage'][i].hasOwnProperty("index")) {
                                tabledata.push({ condition: table.cache['linkage'][i].condition, linkagecontrol: table.cache['linkage'][i].linkagecontrol, linkageevent: table.cache['linkage'][i].linkageevent, index: table.cache['linkage'][i].index });
                            }
                        }
                        return tabledata;
                    }
                }
            };




            //监听行工具事件 删除
            table.on('tool(linkage)', function (obj) {
                var data = obj.data;
                //console.log(obj)
                if (obj.event === 'del') {
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];




                    //删除属性表格数据
                    obj.del();

                    //获取表格数据
                    var linkage = selectData.linkage;
                    linkage.splice(obj.data.index, 1);

                    //重新排序
                    for (var i in linkage) {
                        linkage[i].index = i;
                    }

                    //放入数据
                    selectData.linkage = linkage;
                    //渲染表格
                    tablelinkage.reload({ data: selectData.linkage });
                }
            });





            //头工具栏事件
            table.on('toolbar(linkage)', function (obj) {
                if (obj.event === 'add') {
                    //搜索dom
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectData = domlist[4];

                    //获取数据
                    //var tabledata = newFormEditor.rightAttributes.totaltocontrols.text();


                    var tabledata = selectData.linkage;
                    if (IsEmpty(tabledata)) {
                        tabledata = [];
                    }
                    tabledata.push({ condition: { valuetype: "", fuhao: "", contrastvalue:"",text:"双击编辑"}, linkagecontrol: "", linkageevent:"", index: tabledata.length });

                    tablelinkage.reload({ data: tabledata });

                    selectData.linkage = tabledata;

                    //滚动到最下面
                    //$('#right_Attributes_Content').scrollTop($('#right_Attributes_Content')[0].scrollHeight);

                }
            });

            //条件
            /*
            form.on('switch(laycondition)', function (data) {


                //取当前选择的数据
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];


                //获取当前行tr对象
                var elem = data.othis.parents('tr');
                //data-index
                selectData.linkage[$(elem).attr("data-index")].condition = data.elem.checked;

                selectData.linkage[$(elem).attr("data-index")].index = $(elem).attr("data-index");

            });
            */


            //触发行双击事件
            table.on('rowDouble(linkage)', function (obj) {
                console.log(obj.tr) //得到当前行元素对象
                console.log(obj.data) //得到当前行数据
                //obj.del(); //删除当前行
                //obj.update(fields) //修改当前行数据
                //加载条件页面
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }

                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];

                //初始化页面
               
                var openhtml = "<div style='height:50px' ></div> <div class='layui-form' lay-filter='tiaojianform'> <div class='layui-form-item'>";

                openhtml += '      <label class="layui-form-label">条件</label>';

                openhtml += '      <div class="layui-input-inline" style="width: 100px;">';

                openhtml += '        <select name="valuetype">';
                openhtml += '        <option value="display" >显示值</option>';
                openhtml += '        <option value="hidden" selected="">隐藏值</option>';
                openhtml += '        </select>';

                openhtml += '      </div>';

                openhtml += '      <div class="layui-form-mid"></div>';

                openhtml += '      <div class="layui-input-inline" style="width: 100px;">';
                openhtml += '        <select name="fuhao">';
                openhtml += '        <option value="=" selected="">等于</option>';
                openhtml += '        <option value="!=" >不等于</option>';
                openhtml += '        <option value=">" >大于</option>';
                openhtml += '        <option value="<" >小于</option>';
                openhtml += '        </select>';
                openhtml += '      </div>';

                openhtml += '      <div class="layui-form-mid"></div>';
                openhtml += '      <div class="layui-input-inline" style="width: 100px;">';
                openhtml += '        <input type="text" name="contrastvalue" autocomplete="off" class="layui-input">';
                openhtml += '      </div>';
                openhtml += '    </div></div>';




               
                layer.open({
                    type: 1
                    , title: false //不显示标题栏
                    , closeBtn: false
                    , area: ['500px', '200px']
                    , shade: 0.8
                    , id: 'LAY_layuipro_tiaojian' //设定一个id，防止重复弹出
                    , btn: ['保存', '取消']
                    , btnAlign: 'c'
                    , moveType: 1 //拖拽模式，0或者1
                    , content: openhtml
                    , success: function (layero) {
                        form.render(null, 'tiaojianform');
                        form.val("tiaojianform", selectData.linkage[obj.data.index]["condition"])

                    }
                    ,yes: function (index, layero) {
                        //do something
                        var jsonvalues = form.val("tiaojianform");


                        if (IsEmpty(jsonvalues.valuetype)) {
                            layer.msg('值类型不能为空！', {
                                icon: 2,
                                time: 2000 //2秒关闭
                            });

                            return;
                        }


                        if (IsEmpty(jsonvalues.fuhao)) {
                            layer.msg('计算符号不能为空！', {
                                icon: 2,
                                time: 2000 //2秒关闭
                            });

                            return;
                        }

         


                        if (IsEmpty(jsonvalues.contrastvalue)) {
                            layer.msg('比较值不能为空！', {
                                icon: 2,
                                time: 2000 //2秒关闭
                            });

                            return;
                        }



                        jsonvalues.text = (jsonvalues.valuetype === "display" ? "“显示值”" : "“隐藏值”");

                        switch (jsonvalues.fuhao) {
                            case "=":
                                jsonvalues.text+="等于"
                                break;
                            case "!=":
                                jsonvalues.text += "不等于"
                                break;
                            case ">":
                                jsonvalues.text += "大于"
                                break;
                            case "<":
                                jsonvalues.text += "小于"
                                break;
                            default:
                        }
                        jsonvalues.text += "“"+jsonvalues.contrastvalue+"”";

                        
                        //修改数据
                        selectData.linkage[obj.data.index]["condition"] = jsonvalues;

                        //obj.update(selectData.linkage[obj.data.index]) //修改当前行数据

                        tablelinkage.reload({ data: selectData.linkage });


                        layer.close(index); //如果设定了yes回调，需进行手工关闭

                    }
                });



               
                
            });







            //控件
            form.on('select(selectlinkagecontrol)', function (data) {

                //取当前选择的数据
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];


                //获取当前行tr对象
                var elem = data.othis.parents('tr');
                //data-index
                selectData.linkage[$(elem).attr("data-index")].linkagecontrol = data.value;

                selectData.linkage[$(elem).attr("data-index")].index = $(elem).attr("data-index");

            })

            //事件
            form.on('select(selectlinkageevent)', function (data) {

                //取当前选择的数据
                //搜索dom
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }
                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectData = domlist[4];


                //获取当前行tr对象
                var elem = data.othis.parents('tr');
                //data-index
                selectData.linkage[$(elem).attr("data-index")].linkageevent = data.value;

                selectData.linkage[$(elem).attr("data-index")].index = $(elem).attr("data-index");

            })















            //userdept 用户类型
            newFormEditor.rightAttributes.userdept.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.userdept.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.userdept.dom.html('<label class="layui-form-label">用户类型</label><div class="layui-input-block"><input name="userdept" class="layui-input" required="" readonly type="text" placeholder="请选择用户类型" value="" autocomplete="off" lay-verify="required"> </div></div>');

            //注册用户类型选择 多选
            dictTableSelect.render({
                key: newFormEditor.rightAttributes.userdept.dom.find('input[name^="userdept"]'),
                sysDictClassCode: 'Department',
                type: 'checkbox',
                callback: function (elem, data) {

                    //搜索dom
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectdata = domlist[4];
                    var index = domlist[5];

                    selectdata.userdept = newFormEditor.rightAttributes.userdept.text();

                }
            });


            newFormEditor.rightAttributes.userdept.text = function () {
                if (newFormEditor.rightAttributes.userdept.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "userdept": arguments[0] });

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.userdept;
                    }
                }
            }

            //rolegroup 角色组

            newFormEditor.rightAttributes.rolegroup.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.rolegroup.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.rolegroup.dom.html('<label class="layui-form-label">角色组</label><div class="layui-input-block"><input name="rolegroup" class="layui-input" required="" readonly type="text" placeholder="请选择角色组" value="" autocomplete="off" lay-verify="required"> </div></div>');

            //注册用户类型选择 多选
            dictTableSelect.render({
                key: newFormEditor.rightAttributes.rolegroup.dom.find('input[name^="rolegroup"]'),
                sysDictClassCode: 'RoleGroup',
                type: 'checkbox',
                callback: function (elem, data) {

                    //搜索dom
                    var domlist = getDivAndInpAndLblDom();
                    if (domlist === null) {
                        return;
                    }
                    var divdom = domlist[0];
                    var inpdivdom = domlist[1];
                    var inpdom = domlist[2];
                    var lbldom = domlist[3];
                    var selectdata = domlist[4];
                    var index = domlist[5];

                    selectdata.rolegroup = newFormEditor.rightAttributes.rolegroup.text();

                }
            });


            newFormEditor.rightAttributes.rolegroup.text = function () {
                if (newFormEditor.rightAttributes.rolegroup.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "rolegroup": arguments[0] });

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.rolegroup;
                    }
                }
            }





            //selecttype 选择类型
            newFormEditor.rightAttributes.selecttype.dom = $(document.createElement("div"));
            newFormEditor.rightAttributes.selecttype.dom.addClass('layui-form-item');
            newFormEditor.rightAttributes.selecttype.dom.html('<label class="layui-form-label">选择方式</label><div class="layui-input-block"><select name="selecttype" lay-filter="selecttype"><option value="radio">单选</option><option value="checkbox">多选</option></select></div ></div > ');
            form.on('select(selecttype)', function (data) {
                var domlist = getDivAndInpAndLblDom();
                if (domlist === null) {
                    return;
                }

                var divdom = domlist[0];
                var inpdivdom = domlist[1];
                var inpdom = domlist[2];
                var lbldom = domlist[3];
                var selectdata = domlist[4];
                var index = domlist[5];

                selectdata.selecttype = data.value;

            });

            newFormEditor.rightAttributes.selecttype.text = function () {
                if (newFormEditor.rightAttributes.selecttype.dom !== null) {
                    if (arguments.length > 0) {
                        //赋值
                        form.val('form-attr', { "selecttype": arguments[0] });

                    }
                    else {
                        //取值
                        var data = form.val('form-attr');
                        return data.selecttype;
                    }
                }
            };

















            //渲染数据
            ////日期最大值
            //datemax: {
            //    dom: null,
            //        text: null
            //},
            ////日期最小值
            //datemin: {
            //    dom: null,
            //        text: null
            //},









        }
    };
    /**
     * 获取字典构造函数，用实例化，解决循环异步问题
     * @param {any} opt {data:控件实体,其他随便传递} 返回的参数
     * @param {Function} mycallback 
     */

    var ajaxdict = function (opt, mycallback) {
        if (!dictList.hasOwnProperty(opt.data.dictclass)) {
            //获取数据
            $.ajax({
                type: "post",
                url: '/ShareApi/GetDict',
                data: { sysDictClassCode: opt.data.dictclass, PageIndex: 1, PageSize: 5000000 },//暂定直接加载500W数据 一次性怎么也全部加载出来了
                success: function (msg) {
                    if (msg.code != "0" && msg.code != "-500") {
                        layer.msg("加载字典数据代码：" + opt.data.dictclass + ",失败，原因：" + msg.msg, {
                            icon: 2,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        });
                        mycallback(false, opt);
                        return;
                    }

                    if (msg.code != "-500") {
                        dictList[opt.data.dictclass] = msg.data.list;
                    }
                    else {
                        dictList[opt.data.dictclass] = [];
                    }
                    //加载属性
                    mycallback(true, opt);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg('加载字典数据代码：' + opt.data.dictclass + ',请求失败！', {
                        icon: 2,
                        time: 3000 //3秒关闭
                    });
                    mycallback(false, opt);
                }
            });

        }
        else {
            mycallback(true, opt);
        }


    }


    /**
 * 为空验证 true  空 false  非空
 * @param {any} v
 */
    function IsEmpty(v) {

        switch (typeof v) {

            case 'undefined':
                return true;
            case 'string':
                if (v.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length === 0) return true;
                break;
            case 'boolean':
                if (!v) return true;
                break;
            case 'number':
                if (0 === v || isNaN(v)) return true;
                break;
            case 'object':
                if (null === v || v.length === 0) return true;
                for (var i in v) {

                    return false;

                }
                return true;
        }
        return false;

    }

    /**
     * 根据value找key
     * @param {any} obj
     * @param {any} value
     */
    function findKey(obj, value) {

        var keys = Object.keys(obj);

        for (var i in keys) {
            if (obj[keys[i]] === value) {
                return keys[i];
            }
        }

        return null;
    }

    /**
    * 拖拽控件到指定位置
    * @param {any} div 容器
    * @param {any} newIndex 新增的索引位置ID
    * @param {any} putcontrolsjson 添加的控件集合列表
    */
    formEditor.prototype.dragcontrol = function (div, newIndex, putcontrolsjson) {
        //控件集合
        var control = null;
        for (var i in this.controls) {

            for (var s in this.controls[i].controls) {
                if (this.controls[i].controls[s].tag === div.data('tag')) {
                    control = this.controls[i].controls[s];
                    //获取到数据
                    break;
                }
            }
            if (control !== null) {
                break;
            }
        }

        if (control !== null) {
            //替换数据
            var thisputjson =
            {

            };

            //初始化数据
            for (var f in control.attribute) {
                for (var g in controlAttr) {
                    if (control.attribute[f] === controlAttr[g]) {
                        switch (controlAttr[g]) {
                            case controlAttr.id:
                                //生成id
                                var inpindex = 0;
                                while (true) {
                                    inpindex++;
                                    if ($('#' + control.tag + inpindex).length === 0) {
                                        thisputjson[g] = control.tag + inpindex;
                                        break;
                                    }
                                }
                                break;
                            case controlAttr.title:
                                //生成title
                                var inpindex = 0;
                                while (true) {
                                    inpindex++;
                                    if ($('#' + control.tag + inpindex).length === 0) {
                                        thisputjson[g] = control.tag + inpindex;
                                        break;
                                    }
                                }
                                break;
                            case controlAttr.placeholder:
                                if (control.tag === 'user' || control.tag === 'dict') {
                                    thisputjson[g] = '请选择';
                                }
                                else {
                                    thisputjson[g] = '请输入';
                                }
                                break;
                            case controlAttr.readonly:
                                thisputjson[g] = false;
                                break;
                            case controlAttr.display:
                                thisputjson[g] = false;
                                break;
                            case controlAttr.required:
                                thisputjson[g] = false;
                                break;
                            case controlAttr.tag:
                                thisputjson[g] = control.tag;
                                break;
                            case controlAttr.layouttype:
                                //默认行元素
                                if (newIndex.length > 1) {
                                    thisputjson[g] = 'layui-input-inline';
                                }
                                else {
                                    thisputjson[g] = 'layui-input-block';
                                }
                                break;
                            case controlAttr.laytext:
                                thisputjson[g] = '开启|关闭';
                                break;
                            case controlAttr.layvalue:
                                thisputjson[g] = 'true|false';
                                break;
                            case controlAttr.datetype:
                                thisputjson[g] = 'date';
                                break;
                            case controlAttr.dateformat:
                                thisputjson[g] = 'yyyy-MM-dd';
                                break;
                            case controlAttr.daterange:
                                thisputjson[g] = false;
                                break;
                            case controlAttr.options:
                                if (control.tag === 'select') {
                                    thisputjson[g] = [{ text: '请选择', value: '', index: 0 }];
                                }
                                else {
                                    thisputjson[g] = [{ text: '选项1', value: '选项1', index: 0 }];
                                }
                                break;
                            case controlAttr.controls:
                                //初始化默认值 控件列表
                                thisputjson[g] = [];
                                break;
                            case controlAttr.selecttype:
                                thisputjson[g] = 'radio';
                                break;
                            case controlAttr.userdept:
                            case controlAttr.rolegroup:
                                thisputjson[g] = { text: "", value: "" };
                                break;
                            case controlAttr.isexportexcel:
                                thisputjson[g] = true;
                                break;
                            case controlAttr.issureaddmultiple:
                                thisputjson[g] = false;
                                break;
                            default:
                                thisputjson[g] = '';
                                break;
                        }
                        break;
                    }
                }
            }



            //主要解决维护模式 不可以写入操作 只能通过属性栏操作   因为在维护模式 省的造成不必要麻烦
            //if (thisputjson.isreadonly === true) {
            //    thisputjson.isreadonly = false;
            //}

            //添加序列号
            thisputjson.index = newIndex;
            //创建控件
            div = this.createcontrol(div, thisputjson, this.editortype, putcontrolsjson, this.thisdivid);
            //渲染
            //form.render(null, this.thisdivid)
            //添加集合
            // putcontrolsjson.push(thisputjson);

            //排序
            if (putcontrolsjson.length > 0) {
                var oldIndex = [];
                for (var i = 0; i < newIndex.length; i++) {
                    if ((i + 1) < newIndex.length) {
                        oldIndex.push(newIndex[i]);
                    }
                    else {
                        oldIndex.push(putcontrolsjson.length - 1);
                    }
                }

                //移动到 排序
                if (putcontrolsjson.length > 1) {

                    this.sortputjson(newIndex, oldIndex, putcontrolsjson);
                }
            }

            //模拟单击
            thisputjson.tagdom.click();
        }

    }
    /**
    * 更改 下级节点数据 解决行元素排序，行内元素 序列号出现错误问题
    * @param {any} parentid
    * @param {any} putcontrolsjson
    */
    formEditor.prototype.sortputChilds = function (parentid, putcontrolsjson) {
        if (IsEmpty(putcontrolsjson)) {
            return;
        }

        for (var i in putcontrolsjson) {

            var newIndex = JSON.parse(JSON.stringify(parentid)); 

            var index = putcontrolsjson[i].index[putcontrolsjson[i].index.length - 1];
            newIndex.push(index);
            putcontrolsjson[i].index = newIndex;
            putcontrolsjson[i].tagdom.data('index', newIndex);
            putcontrolsjson[i].tagdom.attr('data-index', newIndex);
            if (putcontrolsjson[i].hasOwnProperty("controls")) {
                //存在下级
                this.sortputChilds(newIndex, putcontrolsjson[i].controls)
            }

        }

    }

    /**
    * 排序
    * @param {any} newIndex 元素新位置
    * @param {any} oldIndex 元素老位置
    * @param {any} putcontrolsjson 操作的控件集合
    */
    formEditor.prototype.sortputjson = function (newIndex, oldIndex, putcontrolsjson) {
        if (newIndex === oldIndex) {
            return true;
        }


        if (newIndex.length !== oldIndex.length) {
            return false;
        }

        //获取父节点
        var ParentIndex = [];
        for (var i = 0; i < newIndex.length; i++) {
            if (newIndex[i] !== oldIndex[i] && i !== newIndex.length - 1) {
                return false;
            }

            if ((i + 1) < newIndex.length) {
                ParentIndex.push(newIndex[i]);
            }
        }

        //获取起始位置
        var newIndex1 = newIndex[newIndex.length - 1];
        //获取结束位置
        var oldIndex1 = oldIndex[oldIndex.length - 1];

        //判断升 还是降
        if (newIndex1 > oldIndex1) {
            //记录降的元素
            var sygjson = putcontrolsjson[oldIndex1];
            //降 老位置 到移动到的位置
            for (var i = oldIndex1; i <= newIndex1; i++) {
                if (i === newIndex1) {
                    //最后一个元素
                    putcontrolsjson[i] = sygjson;
                }
                else {
                    //下一个元素 升级
                    putcontrolsjson[i] = putcontrolsjson[i + 1];
                }
                var IndexSet = [];
                for (var s in ParentIndex) {
                    IndexSet.push(ParentIndex[s]);
                }
                IndexSet.push(i);


                putcontrolsjson[i].index = IndexSet;
                var tagdom = putcontrolsjson[i].tagdom;
                tagdom.data('index', IndexSet);
                tagdom.attr('data-index', IndexSet);

                //排序下级数据
                if (putcontrolsjson[i].hasOwnProperty("controls")) {
                    this.sortputChilds(IndexSet, putcontrolsjson[i].controls);
                }
            }
        }
        else {
            for (var i = oldIndex1; i >= newIndex1; i--) {
                var IndexSet = [];
                for (var s in ParentIndex) {
                    IndexSet.push(ParentIndex[s]);
                }
                IndexSet.push(i);

                if (newIndex1 === i) {
                    putcontrolsjson[i].index = IndexSet;
                    var tagdom = putcontrolsjson[i].tagdom;
                    tagdom.data('index', IndexSet);
                    tagdom.attr('data-index', IndexSet);
                }
                else {
                    //记录上一个元素
                    var lsjson = putcontrolsjson[i - 1];
                    //把上个元素换成当前元素
                    putcontrolsjson[i - 1] = putcontrolsjson[i];
                    //把当前元素  换成上一个元素
                    putcontrolsjson[i] = lsjson;

                    putcontrolsjson[i].index = IndexSet;
                    var tagdom = putcontrolsjson[i].tagdom;
                    tagdom.data('index', IndexSet);
                    tagdom.attr('data-index', IndexSet);
                }

                //排序下级数据
                if (putcontrolsjson[i].hasOwnProperty("controls")) {
                    this.sortputChilds(IndexSet, putcontrolsjson[i].controls);
                }

            }


        }

    }



    /**
     * 生成控件
     * @param {any} div 控件放入的容器dom
     * @param {any} opt 生成控件的json 集合
     * @param {any} editortype 编辑器状态
     * @param {any} putcontrolsjson 数据放入的位置
     * @param {any} renderName 渲染name
     */
    formEditor.prototype.createcontrol = function (div, opt, editortype, putcontrolsjson, renderName) {
        /**实例变量 */
        var newFormEditor = this;

        if (IsEmpty(div)) {
            //创建容器
            div = $(document.createElement("div"));
        }
        div.attr('data-index', opt.index);
        div.data('index', opt.index);

        div.removeClass();
        //行元素 改成正常模式
        //判断是否为行内行

        if (opt.index.length > 1) {
            div.addClass('layui-input-inline');
        }
        else {
            if (opt.tag !== 'row') {
                div.addClass('layui-form-item');
            }
            else {
                div.addClass('layui-form-row');
            }
        }

        if (!IsEmpty(opt) && !IsEmpty(opt.tag)) {
            //生成控件
            var controljson = null;
            for (var i in this.controls) {

                for (var s in this.controls[i].controls) {
                    if (this.controls[i].controls[s].tag === opt.tag) {
                        controljson = this.controls[i].controls[s];
                        //获取到数据
                        break;
                    }
                }
                if (controljson !== null) {
                    break;
                }
            }
            if (controljson === null) {
                return null;
            }

            var controlhtml = controljson.html;
            //放入容器
            div.html(controlhtml);

            //添加dom
            opt.tagdom = div;
            //添加集合
            putcontrolsjson.push(opt);

            //添加元素搜索类型
            opt.domtype = controljson.domtype;

            //注册事件
            if (editortype === editorformstate.repair) {
                //注册事件
                opt.tagdom.on("click", function () {
                    var e = window.event || e;
                    if (e.stopPropagation) {
                        e.stopPropagation();
                    }
                    else {
                        e.cancelBubble = true;
                    }

                    var thisdom = $(this);
                    //单机事件
                    if (thisdom.hasClass("active")) {
                        return;
                    }

                    $("#" + newFormEditor.thisdivid + " .active").removeClass('active');
                    var widgetviewaction = $("#widget-view-action");
                    var widgetviewdrag = $("#widget-view-drag");
                    if (widgetviewdrag.is(':hidden')) {
                        widgetviewdrag.show();
                    }
                    if (widgetviewaction.is(':hidden')) {
                        widgetviewaction.show();
                    }
                    //$("#widget-view-action .layui-icon-delete").data('index', thisdom.data('index'));

                    //设置选择的索引

                    newFormEditor.SelectIndexControl = thisdom.data('index');

                    //获取对应数据
                    var index = 0;
                    var Parentindex = [];
                    var putcontrolsjson = newFormEditor.putjson;
                    for (var i in newFormEditor.SelectIndexControl) {
                        if ((i + 1) < newFormEditor.SelectIndexControl.length) {
                            putcontrolsjson = putcontrolsjson[newFormEditor.SelectIndexControl[i]].controls;
                            Parentindex.push(newFormEditor.SelectIndexControl[i]);
                        }
                        else {
                            //putcontrolsjson = putcontrolsjson[newFormEditor.SelectIndexControl[i]];
                            index = newFormEditor.SelectIndexControl[i];
                        }
                    }
                    thisdom.addClass('active');
                    thisdom.append(widgetviewaction);
                    thisdom.append(widgetviewdrag);
                    //加载右侧属性列表
                    if (index >= 0 && index < putcontrolsjson.length) {
                        //获取属性列表
                        var controljson = null;
                        for (var i in newFormEditor.controls) {

                            for (var s in newFormEditor.controls[i].controls) {
                                if (newFormEditor.controls[i].controls[s].tag === putcontrolsjson[index].tag) {
                                    controljson = newFormEditor.controls[i].controls[s];
                                    //获取到数据
                                    break;
                                }
                            }

                            if (controljson !== null) {
                                break;
                            }
                        }
                        if (controljson === null) {
                            return;
                        }

                        //全部隐藏属性栏
                        for (var i in newFormEditor.rightAttributes) {
                            if (!IsEmpty(newFormEditor.rightAttributes[i].dom)) {
                                newFormEditor.rightAttributes[i].dom.hide();
                            }
                        }

                        //打开对应数据
                        for (var i in controljson.attribute) {
                            var key = findKey(controlAttr, controljson.attribute[i]);
                            if (!IsEmpty(key) && !IsEmpty(newFormEditor.rightAttributes[key]) && !IsEmpty(newFormEditor.rightAttributes[key].dom)) {
                                var IsFind = false;
                                var context = '';
                                if (newFormEditor.SelectIndexControl.length <= 1 || controljson.attribute[i] !== controlAttr.layouttype) {
                                    IsFind = true;
                                    context = putcontrolsjson[index][key];
                                }

                                if (IsFind) {
                                    newFormEditor.rightAttributes[key].text(context);

                                    //默认隐藏项
                                    if (key !== 'numbermin' && key !== 'numbermax' && key !== 'multiplemax' && key !== 'defaultmultiple') {
                                        newFormEditor.rightAttributes[key].dom.show();
                                    }
                                    
                                }


                            }
                        }






                    }

                });


                //父节点位置
                var Parentindex = [];
                for (var i = 0; i < opt.index.length; i++) {
                    if ((i + 1) < opt.index.length) {
                        Parentindex.push(opt.index[i]);
                    }
                }


                if (Parentindex.length > 0) {

                    var ParentDom = newFormEditor.putjson;
                    //存在父节点
                    for (var i = 0; i < Parentindex.length; i++) {
                        if ((i + 1) < Parentindex.length) {
                            ParentDom = ParentDom[Parentindex[i]].controls;
                        }
                        else {
                            ParentDom = ParentDom[Parentindex[i]].tagdom;
                        }
                    }

                    if (ParentDom !== null && !Array.isArray(ParentDom)) {
                        var rowempty = ParentDom.children('.layui-form').children('.layui-row.layui-empty');
                        //去除提示文本
                        if (rowempty.length > 0) {
                            //根节点删除
                            rowempty.remove('.layui-row.layui-empty');
                        }
                    }
                }
                else {
                    var rowempty = $('#' + newFormEditor.thisdivid).children('.layui-row.layui-empty');
                    //去除提示文本
                    if (rowempty.length > 0) {
                        //根节点删除
                        rowempty.remove('.layui-row.layui-empty');
                    }
                    if (opt.tag === 'row') {
                        //添加默认提示
                        opt.tagdom.children('.layui-form').append('<div class="layui-row layui-empty">从左侧拖拽控件到此设计区域来添加字段</div>');
                        //注册拖拽事件
                        //注册编辑器内容排序新增 删除 修改 事件
                        new Sortable(opt.tagdom.children('.layui-form')[0], {
                            group: {
                                name: 'editrowcontent',
                                pull: false,
                                put: 'leftSortableid'
                            },
                            animation: 150,
                            onAdd: function (evt) {
                                var item = $(evt.item);
                                if (item.data('tag') === 'row') {
                                    layer.msg('行内不允许在添加行！', {
                                        icon: 2,
                                        time: 3000
                                    });
                                    item.remove();
                                    return;
                                }
                                var newindex = 0;
                                //判断级别
                                var parentdiv = $(evt.item).parent().parent();
                                if (parentdiv.children('.layui-form').children('.layui-row.layui-empty').length < 1) {
                                    newindex = evt.newIndex;
                                };


                                var parentindex = parentdiv.data("index");
                                var thisnewindex = [];
                                var thisputjson = newFormEditor.putjson;
                                for (var i = 0; i < parentindex.length; i++) {
                                    thisnewindex.push(parentindex[i]);
                                    thisputjson = thisputjson[parentindex[i]].controls;
                                }
                                thisnewindex.push(newindex);

                                newFormEditor.dragcontrol(item, thisnewindex, thisputjson)
                            },
                            onUpdate: function (evt) {
                                //排序
                                //判断级别
                                var parentdiv = $(evt.item).parent().parent();
                                var parentindex = parentdiv.data("index");
                                var thisnewindex = [];
                                var thisoldindex = [];
                                var thisputjson = newFormEditor.putjson;
                                for (var i = 0; i < parentindex.length; i++) {
                                    thisnewindex.push(parentindex[i]);
                                    thisoldindex.push(parentindex[i]);
                                    thisputjson = thisputjson[parentindex[i]].controls;
                                }
                                thisnewindex.push(evt.newIndex);
                                thisoldindex.push(evt.oldIndex);
                                newFormEditor.sortputjson(thisnewindex, thisoldindex, thisputjson);
                                //设置当前选择
                                newFormEditor.SelectIndexControl = thisnewindex;

                            }

                        });


                    }
                }
            }

            //主要解决异步加载数据问题


            if (editortype !== editorformstate.repair && !IsEmpty(opt.dictclass) && opt.tag !== "dict") {
                //进行加载数据
                new ajaxdict({ data: opt, renderName: renderName }, loadattribute);
            }
            else {
                //直接加载
                loadattribute(true, { data: opt, renderName: renderName });
            }


        }

        /**加载属性 
         { dataList 创建的控件json实体,renderName form渲染的容器 属性lay-filter 值}
         success 成功或者失败
         */
        function loadattribute(success, dataList) {
            if (!success) {
                return;
            }

            var data = dataList.data;
            var renderName = dataList.renderName;
            //控件操作对象
            var divinpdom = null;
            var titlefieldset = null;
            var titlelegend = null;
            if (data.tag === 'row') {
                //行容器
                divinpdom = data.tagdom.children('.layui-form');
            }
            else {
                if (data.tag === 'title') {
                    titlefieldset = div.find('fieldset[class^="layui-elem-field layui-field-title"]');
                    titlelegend = titlefieldset.find("legend");
                }
                divinpdom = div.find('div[class^="layui-input-block"]');
                if (divinpdom.length < 1) {
                    divinpdom = div.find('div[class^="layui-input-inline"]');
                }
            }
            var inpdom = divinpdom.find(controljson.domtype);
            //标题操作对象
            var lbldom = div.find('label[class^="layui-form-label"]');


            //生成对象属性
            for (var i in controljson.attribute) {
                var key = null;
                for (var f in controlAttr) {
                    if (controljson.attribute[i] === controlAttr[f]) {
                        key = f;
                        break;
                    }
                }

                if (!IsEmpty(key) && !IsEmpty(data[key])) {

                    switch (controlAttr[key]) {
                        case controlAttr.id:
                            //控件ID
                            inpdom.attr("name", data[key])
                            inpdom.attr("lay-filter","lay_"+data[key])
                            div.attr("id", data[key]);
                            div.attr('data-id', data[key]);
                            div.data('id', data[key]);

                            if (controljson.tag === 'date') {
                                //增加一个ID
                                inpdom.attr('id', 'date_' + data[key])
                            }
                            div.attr("id", data[key]);
                            
                            break;
                        case controlAttr.title:
                            //控件标题
                            if (controljson.tag === 'title') {
                                data.tagdom.find(controljson.domtype).html(data[key]);
                            }
                            else {
                                lbldom.html(data[key]);
                            }


                            break;
                        case controlAttr.tag:
                            //控件类型
                            div.attr('data-tag', data[key]);
                            div.data('tag', data[key]);
                            break;
                        case controlAttr.placeholder:
                            if (editortype !== editorformstate.read) {
                                //搜索dom
                                inpdom.attr("placeholder", data[key])
                            }
                            else {
                                //搜索dom
                                inpdom.attr("placeholder", "")
                            }


                            break;
                        case controlAttr.defaulttext:
                            //默认值

                            if (data.tag === 'checkbox') {
                                var defaulttext = [];
                                if (data[key].indexOf(',') > -1) {
                                    defaulttext = data[key].split(',');
                                }
                                else {
                                    defaulttext = [data[key]];
                                }

                                if (inpdom.length > 0) {
                                    inpdom.val(defaulttext);
                                }
                            }
                            else {
                                switch (data.tag) {
                                    case 'switch':
                                        //取隐藏值
                                        //
                                        if (data.hasOwnProperty("layvalue") && !IsEmpty(data.layvalue) && data.layvalue.split('|').length > 1) {
                                            inpdom.prop('checked', (data[key] == data.layvalue.split('|')[0]) ? true : false);
                                        }
                                        else {
                                            inpdom.prop('checked', (data[key] == 'true' || data[key] == 'on') ? true : false);
                                        }

                                        break;
                                    case 'radio':
                                        inpdom.val([data[key]]);
                                        break;
                                    default:
                                        inpdom.val(data[key]);
                                        break;
                                }

                            }
                            break;
                        case controlAttr.width:
                            //inpdom.css('width', data[key]);
                            divinpdom.css('width', data[key]);
                            break;
                        case controlAttr.titlewidth:

                            lbldom.css('width', data[key]);


                            /*
                             layui-input-inline
                             */
                            if (data.layouttype == 'layui-input-block') {
                                if (!IsEmpty(data[key])) {
                                    divinpdom.css('margin-left', (Number(data[key]) + 30));
                                }
                                else {

                                    divinpdom.css('margin-left', '');

                                }
                            }




                            break;
                        case controlAttr.textsize:
                            //文字大小
                            if (data.tag == "title") {
                                //字体大小
                                //样式：layui-elem-field layui-field-title，下方节点fieldset

                                if (!IsEmpty(data[key])) {
                                    titlelegend.css('font-size', data[key] + "px");
                                    titlelegend.css('line-height', (Number(data[key]) + 6) + "px");
                                }
                                else {
                                    titlelegend.css('font-size', data[key]);
                                    titlelegend.css('line-height', (data[key]));
                                }
                            }
                            else {
                                //lbl字体大小
                                if (!IsEmpty(data[key])) {
                                    lbldom.css('font-size', data[key] + "px");
                                    lbldom.css('line-height', (Number(data[key]) + 6) + "px");
                                }
                                else {
                                    lbldom.css('font-size', data[key]);
                                    lbldom.css('line-height', (data[key]));
                                }


                            }

                            break;
                        case controlAttr.textcolour:
                            //字体颜色
                            if (data.tag == "title") {
                                //字体大小
                                //样式：layui-elem-field layui-field-title，下方节点fieldset
                                titlelegend.css("color", data[key]);
                            }
                            else {
                                //lbl字体大小
                                lbldom.css("color", data[key]);
                            }
                            break;
                        case controlAttr.isreadonly:
                            inpdom.attr("readonly", data[key]);
                            break;
                        case controlAttr.display:
                            //不等于维护状态 隐藏
                            if (editortype !== editorformstate.repair) {
                                if (data[key] === true || data[key] === 'on' || data[key] === 'true') {
                                    div.css("display", "none");
                                }
                                else {
                                    div.css("display", "block");
                                }
                            }
                            break;
                        case controlAttr.required:
                            var value = data[key] === true ? "required" : ""
                            var verify = inpdom.attr("lay-verify");
                            if (!IsEmpty(verify)) {
                                if (value === 'required') {
                                    if (verify.indexOf('required') < 0) {
                                        //赋值
                                        verify = 'required|' + verify;
                                        inpdom.attr("lay-verify", verify);
                                    }
                                }
                                else {
                                    //删除
                                    if (verify.indexOf('required|') > -1) {

                                        inpdom.attr("lay-verify", verify.replace(new RegExp("required|", "g"), ''));
                                    }
                                    else if (verify.indexOf('required') > -1) {

                                        inpdom.attr("lay-verify", verify.replace(new RegExp("required", "g"), ''));
                                    }
                                }
                            }
                            else {
                                inpdom.attr("lay-verify", value);
                            }

                            break;
                        case controlAttr.layverify:
                            var verify = inpdom.attr("lay-verify");
                            if (!IsEmpty(verify) && verify.indexOf('required') > -1) {

                                inpdom.attr("lay-verify", 'required|' + data[key]);
                            }
                            else {
                                inpdom.attr("lay-verify", data[key]);
                            }
                            break;
                        case controlAttr.height:
                            inpdom.css('height', data[key]);
                            break;
                        case controlAttr.wordaux:
                            //增加布局类型  样式不动了
                            //div.removeClass();
                            //div.addClass("layui-input-inline");
                            var wordaux = div.find('div[class^="layui-form-mid layui-word-aux"]');
                            if (wordaux.length > 0) {
                                wordaux.html(data[key]);
                            }
                            else {
                                div.append('<div class="layui-form-mid layui-word-aux">' + data[key] + '</div>');
                            }
                            break;
                        case controlAttr.layReqtext:
                            inpdom.attr('lay-reqtext', data[key]);
                            break;
                        case controlAttr.layouttype:
                            //div.removeClass();
                            //div.addClass(data[key]);
                            divinpdom.removeClass();
                            divinpdom.addClass(data[key]);
                            break;
                        case controlAttr.laytext:
                            inpdom.attr("lay-text", data[key]);
                            break;
                        case controlAttr.layvalue:
                            inpdom.attr("lay-value", data[key]);
                        case controlAttr.options:
                            if (!IsEmpty(data.options) && Array.isArray(data.options) && data.options.length > 0) {
                                //生成对象
                                for (var k in data.options) {
                                    if (!IsEmpty(data.options[k]) && data.options[k].hasOwnProperty("text") && data.options[k].hasOwnProperty("value")) {
                                        switch (data.tag) {
                                            case 'select':

                                                inpdom.append("<option value='" + data.options[k].value + "'>" + data.options[k].text + "</option>");

                                                if (k == 0 && data.isowndefinition == true || data.isowndefinition == 'true') {

                                                    inpdom.append("<option value='OwnDefinition'></option>");
                                                }
                                                break;
                                            case 'checkbox':
                                                divinpdom.append("<input name='" + data.id + "' title='" + data.options[k].text + "' type='checkbox' lay-vertype='tips' value='" + data.options[k].value + "'></input>");
                                                //添加了内容，需要更新内容
                                                inpdom = divinpdom.find(controljson.domtype);
                                                break;
                                            case 'radio':
                                                divinpdom.append("<input name='" + data.id + "' title='" + data.options[k].text + "' type='radio' value='" + data.options[k].value + "'></input>");
                                                //添加了内容，需要更新内容
                                                inpdom = divinpdom.find(controljson.domtype);
                                                break;
                                            default:
                                        }


                                    }
                                }

                            }
                            break;
                        case controlAttr.totaltocontrols:
                            if (!IsEmpty(data.totaltocontrols)) {
                                //注册输入事件
                                //文本框更改文字事件
                                var oneventname = '';

                                if (!!window.ActiveXObject || "ActiveXObject" in window) {
                                    //IE
                                    oneventname = 'propertychange';
                                } else {
                                    //非IE
                                    oneventname = 'oninput';
                                }
                                inpdom.data("totaltocontrols", data.totaltocontrols);

                                inpdom.on('input ' + oneventname, function () {
                                    totaltocontrolstotaltocontrols($(this));

                                });

                            }

                        

                            break;
                        case controlAttr.dictclass:
                            //根据字典绑定数据，用于编辑状态，维护浏览状态不触发
                            if (editortype !== editorformstate.repair && !IsEmpty(data.dictclass)) {
                                var dict = dictList[data.dictclass];
                                for (var i in dict) {
                                    switch (data.tag) {
                                        case 'select':
                                            inpdom.append("<option " + (dict[i].sysDictIsSelect.toString().toLowerCase() != "true" ? "disabled" : "") + " value='" + dict[i].sysDictCode + "'>" + dict[i].sysDictContent + "</option>");
                                            break;
                                        case 'checkbox':
                                            divinpdom.append("<input name='" + data.id + "' " + (dict[i].sysDictIsSelect.toString().toLowerCase() != "true" ? "disabled" : "") + " title='" + dict[i].sysDictContent + "' type='checkbox' value='" + dict[i].sysDictCode + "' lay-vertype='tips'></input>");
                                            //添加了内容，需要更新内容
                                            inpdom = divinpdom.find(data.domtype);
                                            break;
                                        case 'radio':
                                            divinpdom.append("<input name='" + data.id + "' " + (dict[i].sysDictIsSelect.toString().toLowerCase() != "true" ? "disabled" : "") + " title='" + dict[i].sysDictContent + "' type='radio' value='" + dict[i].sysDictCode + "'></input>");
                                            //添加了内容，需要更新内容
                                            inpdom = divinpdom.find(data.domtype);
                                            break;
                                        default:
                                    }
                                }

                            }

                            break;
                        case controlAttr.controls:

                            //生成里面的数据
                            if (!IsEmpty(data.controls) && data.controls.length > 0) {
                                var controls = [];
                                for (var hh in data.controls) {
                                    var divchildren = $(document.createElement("div"));
                                    divinpdom.append(divchildren);
                                    //初始化数据
                                    newFormEditor.createcontrol(divchildren, data.controls[hh], editortype, controls, renderName);

                                }
                                data.controls = controls;
                            }

                            break;
                        case controlAttr.totalproportion:
                            inpdom.data("totalproportion", data.totalproportion);
                            break;
                        case controlAttr.linkage:
                            //事件注册 
                             //lay-filter  lay_id

                            switch (data.tag) {
                                case "select":
                                     //选择框事件


                                    if (!IsEmpty(data.linkage) && data.linkage.length > 0) {

                                        inpdom.data("linkage", data.linkage);

                                    }

                                    form.on('select(lay_' + data.id + ')', function (sedata) {
                                        var datalinkage = $(sedata.elem).data("linkage");
                                        for (var lke in datalinkage) {
                                            if (IsEmpty(datalinkage[lke])) {
                                                continue;
                                            }
                                            //获取控件值
                                            var linkagevalue = "";

                                            if (datalinkage[lke].condition.valuetype === 'display') {
                                                linkagevalue = sedata.text;

                                            }
                                            else if (datalinkage[lke].condition.valuetype === 'hidden') {
                                                //隐藏值
                                                linkagevalue = sedata.value;
                                            }
                                            if (IsEmpty(linkagevalue)) {
                                                continue;
                                            }


                                            controlevent(linkagevalue, datalinkage[lke].condition.fuhao, datalinkage[lke].condition.contrastvalue, $("#" + datalinkage[lke].linkagecontrol), datalinkage[lke].linkageevent);

                                        }
                                        //渲染数据
                                        form.render();

                                    });

                                    break;
                                case "radio":
                                    //单选框事件
   
                                    if (!IsEmpty(data.linkage) && data.linkage.length > 0) {

                                        inpdom.data("linkage", data.linkage);

                                    }

                                    form.on('radio(lay_' + data.id + ')', function (radata) {
                                        var datalinkage = $(radata.elem).data("linkage");
                                        for (var lke in datalinkage) {
                                            if (IsEmpty(datalinkage[lke])) {
                                                continue;
                                            }
                                            //获取控件值
                                            var linkagevalue = "";

                                            if (datalinkage[lke].condition.valuetype === 'display') {
                                                linkagevalue = $(radata.elem).attr("title");

                                            }
                                            else if (datalinkage[lke].condition.valuetype === 'hidden') {
                                                //隐藏值
                                                linkagevalue = radata.value;
                                            }
                                            if (IsEmpty(linkagevalue)) {
                                                continue;
                                            }


                                            controlevent(linkagevalue, datalinkage[lke].condition.fuhao, datalinkage[lke].condition.contrastvalue, $("#" + datalinkage[lke].linkagecontrol), datalinkage[lke].linkageevent);


                                        }
                                        //渲染数据
                                        form.render();

                                    }); 







                                    break;
                                case "checkbox":
                                    //多选框事件
                                    if (!IsEmpty(data.linkage) && data.linkage.length > 0) {

                                        inpdom.data("linkage", data.linkage);

                                    }

                                    form.on('checkbox(lay_' + data.id + ')', function (chdata) {
                                        var datalinkage = $(chdata.elem).data("linkage");
                                        for (var lke in datalinkage) {
                                            if (IsEmpty(datalinkage[lke])) {
                                                continue;
                                            }
                                            //获取控件值
                                            var linkagevalue = "";

                                            if (datalinkage[lke].condition.valuetype === 'display') {
                                                linkagevalue = $(chdata.elem).attr("title");

                                            }
                                            else if (datalinkage[lke].condition.valuetype === 'hidden') {
                                               //隐藏值
                                                linkagevalue = chdata.value;
                                            }
                                            if (IsEmpty(linkagevalue)) {
                                                continue;
                                            }


                                            controlevent(linkagevalue, datalinkage[lke].condition.fuhao, datalinkage[lke].condition.contrastvalue, $("#" + datalinkage[lke].linkagecontrol), datalinkage[lke].linkageevent);


                                        }
                                        //渲染数据
                                        form.render();

                                    }); 

                                    break;
                                case "switch":
                                    //开关事件
                                    if (!IsEmpty(data.linkage) && data.linkage.length > 0) {
             
                                       
                                        inpdom.data("linkage", data.linkage);


                                        form.on('switch(lay_' + data.id + ')', function (swdata) {

                                            var datalinkage = $(swdata.elem).data("linkage");

                                            for (var lke in datalinkage) {
                                                //操作事件
                                                //获取对比数据值
                                                
                                                
                                                if (IsEmpty(datalinkage[lke])) {
                                                    continue;
                                                }
                                                //获取控件值
                                                var linkagevalue = "";
                                                if (datalinkage[lke].condition.valuetype === 'display') {
                                                    var spvalue = $(swdata.elem).attr("lay-text").split('|');
                                                    if (spvalue.length > 1) {
                                                        //获取显示值
                                                        if (swdata.elem.checked || swdata.elem.checked === true || swdata.elem.checked === 'true') {
                                                            linkagevalue = $(swdata.elem).attr("lay-text").split('|')[0];
                                                        }
                                                        else
                                                        {
                                                            linkagevalue = $(swdata.elem).attr("lay-text").split('|')[1];
                                                        }
                                                       
                                                    }
                                                  
                                                }
                                                else if (datalinkage[lke].condition.valuetype === 'hidden') {
                                                    //获取隐藏值
                                                    if (swdata.elem.checked || swdata.elem.checked === true || swdata.elem.checked === 'true') {
                                                        linkagevalue = $(swdata.elem).attr("lay-value").split('|')[0];
                                                    }
                                                    else {
                                                        linkagevalue = $(swdata.elem).attr("lay-value").split('|')[1];
                                                    }
                                                       // linkagevalue = swdata.value;
                                                }
                                                if (IsEmpty(linkagevalue)) {
                                                    linkagevalue = swdata.elem.checked;
                                                }


                                                controlevent(linkagevalue, datalinkage[lke].condition.fuhao, datalinkage[lke].condition.contrastvalue, $("#" + datalinkage[lke].linkagecontrol),datalinkage[lke].linkageevent);

                                            }
                                            //渲染数据
                                            form.render();
                                        }); 
                                        
                
                                    }

                                    break;
                                case "dict":
                                    //字典文本框回调事件
                                    //暂时不想写，没有这样的需求
                                    break;
                                default:
                            }
                           

                            break;
                        case controlAttr.seehide:
                            //查看情况是否隐藏控件
                            if (editortype === editorformstate.read) {
                                if (data[key] === true || data[key] === 'on' || data[key] === 'true') {
                                    div.css("display", "none");
                                }
                                else {
                                    div.css("display", "block");
                                }
                            }

                            break;
                        case controlAttr.textdatatype:
                            //文本框输入事件，判断数据类型限制输入
                            inpdom.data("textdatatype", data[key]);


                            if (!IsEmpty(data[key]) && inpdom.data("focusout_bd")!=="1") {

                                //注册失去焦点事件
                                inpdom.focusout(function () {

                                    textdataverification($(this));
                                });

                                inpdom.data("focusout_bd","1");

                            }
                            break;
                        case controlAttr.textdatalength:
                            //数据长度，整数长度，浮点位数
                            inpdom.data("textdatalength", data[key]);

                            if (!IsEmpty(data[key]) && inpdom.data("focusout_bd") !== "1") {

                                //注册失去焦点事件
                                inpdom.focusout(function () {

                                    textdataverification($(this));
                                });
                                inpdom.data("focusout_bd", "1");

                            }

                            break;
                        case controlAttr.isexportexcel:
                            //是否导出excel
                            inpdom.data("isexportexcel", data[key]);
                            inpdom.attr("isexportexcel", data[key]);
                            break;
                        case controlAttr.numbermin:
                            inpdom.data("numbermin", data[key]);
                            if (!IsEmpty(data[key]) && inpdom.data("focusout_bd") !== "1") {

                                //注册失去焦点事件
                                inpdom.focusout(function () {

                                    textdataverification($(this));
                                });
                                inpdom.data("focusout_bd", "1");

                            }
                            break;
                        case controlAttr.numbermax:
                            inpdom.data("numbermax", data[key]);

                            if (!IsEmpty(data[key]) && inpdom.data("focusout_bd") !== "1") {

                                //注册失去焦点事件
                                inpdom.focusout(function () {

                                    textdataverification($(this));
                                });
                                inpdom.data("focusout_bd", "1");

                            }

                            break;

                        case controlAttr.issureaddmultiple:
                            //是否可以添加多条
                            //生成添加一条，删除一条图标
                            if (editortype !== editorformstate.repair) {
                                var adddeldiv = $(document.createElement("div"));
                                adddeldiv.addClass("widget-view-action");

                                var add = $(document.createElement("i"));
                                add.addClass("layui-icon layui-icon-add-1");

                                var del = $(document.createElement("i"));
                                del.addClass("layui-icon layui-icon-delete");

                                adddeldiv.append(add);
                                adddeldiv.append(del);

                                div.append(adddeldiv);
                                div.data("renderName", renderName);
                                div.data("editortype", editortype);

                                if (editortype === editorformstate.read) {
                                    //隐藏新增
                                    adddeldiv.hide();
                                }

                                add.on("click", function () {

                                    //添加事件
                                    //当前数据个数，空为默认1个
                                    var parentDiv = $(this).parent().parent();
                                    //数据当前个数
                                    var datalength = parentDiv.data("datalistlength");
                                    //最大条目
                                    var multiplemax = parentDiv.data("multiplemax");
                                    //渲染的容器
                                    var renderName = parentDiv.data("renderName");
                                    var editortype = parentDiv.data("editortype");


                                    if (IsEmpty(datalength)) {
                                        datalength = 0;
                                    }
                                    else {
                                        datalength = parseInt(datalength)
                                    }

                                    if (IsEmpty(multiplemax) || multiplemax === '0' || multiplemax === 0) {
                                        multiplemax = 99999999;
                                    }
                                    else {
                                        multiplemax = parseInt(multiplemax)
                                    }

                                    if ((datalength + 1) >= multiplemax) {
                                        //不允许添加
                                        layer.tips('最大只能添加' + multiplemax + '条！', $(this), {
                                            tips: 1
                                        });
                                        return;

                                    }


                                    //获取当前元素下方所有控件
                                    //搜搜到当前元素
                                    var controlsList = null;
                                    for (var i in newFormEditor.putjson) {
                                        if (newFormEditor.putjson[i].id === parentDiv.attr("id")) {
                                            //拷贝新的对象 否则引用传递问题，修改了ID会导致数据紊乱。
                                            controlsList = JSON.parse(JSON.stringify(newFormEditor.putjson[i].controls));
                                            break;
                                        }
                                    }

                                    if (IsEmpty(controlsList)) {
                                        layer.tips('行元素内无控件，无法添加！', $(this), {
                                            tips: 1
                                        });
                                        return;
                                    }

                                    var divchildrentop = $(document.createElement("div"));
                                    divchildrentop.addClass("layui-form");
                                    var controls = [];


                                    for (var jj in controlsList) {
                                        var divchildren = $(document.createElement("div"));
                                        //更改ID
                                        controlsList[jj].id = controlsList[jj].id + "_dynamic_" + datalength;
                                        divchildrentop.append(divchildren);
                                        //初始化数据
                                        newFormEditor.createcontrol(divchildren, controlsList[jj], editortype, controls, renderName);



                                    }
                                    //添加到数据里面去
                                    $(this).parent().before(divchildrentop);
                                    //渲染数据
                                    form.render();
                                    parentDiv.data("datalistlength", (datalength + 1));


                                });

                                del.on("click", function () {
                                    //删除事件
                                    //当前数据个数，空为默认1个
                                    var parentDiv = $(this).parent().parent();
                                    //数据当前个数
                                    var datalength = parentDiv.data("datalistlength");
                                    //最大条目
                                    var multiplemax = parentDiv.data("multiplemax");
                                    //渲染的容器
                                    var renderName = parentDiv.data("renderName");
                                    var editortype = parentDiv.data("editortype");


                                    if (IsEmpty(datalength)) {
                                        datalength = 0;
                                    }
                                    else {
                                        datalength = parseInt(datalength)
                                    }

                                    if (IsEmpty(multiplemax) || multiplemax === '0' || multiplemax === 0) {
                                        multiplemax = 99999999;
                                    }
                                    else {
                                        multiplemax = parseInt(multiplemax)
                                    }

                                    if (datalength < 1) {
                                        layer.tips('最少保留一条数据，不允许删除！', $(this), {
                                            tips: 1
                                        });
                                        return;
                                    }

                                    $(this).parent().prev().remove();
                                    parentDiv.data("datalistlength", (datalength - 1));

                                });

                            }

                            break;
                        case controlAttr.defaultmultiple:
                            //默认属性，必须在issureaddmultiple 是否可以添加多个属性后面执行，

                            //默认个数
                            if (editortype !== editorformstate.repair) {
                                div.data("defaultmultiple", data[key]);
                                if (!IsEmpty(data[key]) && parseInt(data[key]) > 1) {
                                    for (var oi = 0; oi < parseInt(data[key]) - 1; oi++) {
                                        //搜索添加事件
                                        div.children(".widget-view-action").children(".layui-icon-add-1").click();
                                        //div.children(".widget-view-action").children(".layui-icon-add-1").click();
                                    }
                                }
                            }

                            break;
                        case controlAttr.multiplemax:
                            //最大条目
                            div.data("multiplemax", data[key]);
                            break;
                        default:
                            break;
                    }
                }
            }

            if (data.tag === 'row' && (data.issureaddmultiple === true || data.issureaddmultiple === 'true') && !IsEmpty(data.controls) && data.controls.length > 0) {

                if (!IsEmpty(newFormEditor.values) && !IsEmpty(newFormEditor.values[data.id]) && !IsEmpty(newFormEditor.values[data.id].text) ) {
                    //修改对象
                    var divdatalistlength = div.data("datalistlength");

                    var valdatalistlength = newFormEditor.values[data.id].text;

                    if (IsEmpty(divdatalistlength)) {
                        divdatalistlength = 1;
                    }
                    else {
                        divdatalistlength = parseInt(divdatalistlength);
                        divdatalistlength = divdatalistlength + 1;
                    }


                    if (IsEmpty(valdatalistlength)) {
                        valdatalistlength = 1;
                    }
                    else {
                        valdatalistlength = parseInt(valdatalistlength)
                    }

                    if (divdatalistlength > valdatalistlength) {
                        //删除元素
                        var fori = divdatalistlength - valdatalistlength;
                        for (var fg = 0; fg < fori; fg++) {
                            div.children(".widget-view-action").children(".layui-icon-delete").click();
                        }

                    } else if (divdatalistlength < valdatalistlength) {
                        var fori = valdatalistlength - divdatalistlength;

                        for (var hj = 0; hj < fori; hj++) {
                            div.children(".widget-view-action").children(".layui-icon-add-1").click();
                        }

                    }

                    divinpdom.data("datalistlength", valdatalistlength);


                }
               
              

            }

            if (!IsEmpty(inpdom) && inpdom.length > 0) {
                //模式状态设定不可写
                if (editortype === editorformstate.repair || editortype === editorformstate.read) {
                    inpdom.attr('disabled', true);
                }

                if (editortype !== editorformstate.repair) {
                    //初始化数据 赋值
                    if (newFormEditor.values.hasOwnProperty(data.id)) {
                        switch (data.tag) {
                            case 'checkbox':
                                var text = [];
                                if (!IsEmpty(newFormEditor.values[data.id])) {
                                    if (!IsEmpty(newFormEditor.values[data.id].value)) {

                                        if (newFormEditor.values[data.id].value.indexOf(",") != -1) {
                                            text = newFormEditor.values[data.id].value.split(",");
                                        }
                                        else {
                                            text.push(newFormEditor.values[data.id].value);;
                                        }
                                    }
                                }
                                if (inpdom.length > 0) {
                                    inpdom.val(text);
                                    //执行一次事件

                                    var datalinkage = data.linkage;
                                    for (var lke in datalinkage) {
                                        if (IsEmpty(datalinkage[lke])) {
                                            continue;
                                        }
                                        //获取控件值
                                        var linkagevalue = "";
                                        if (datalinkage[lke].condition.valuetype === 'display') {
                                            linkagevalue = newFormEditor.values[data.id].text;

                                        }
                                        else if (datalinkage[lke].condition.valuetype === 'hidden') {
                                            //隐藏值
                                            linkagevalue = newFormEditor.values[data.id].value;
                                        }
                                        if (IsEmpty(linkagevalue)) {
                                            continue;
                                        }
                                        controlevent(linkagevalue, datalinkage[lke].condition.fuhao, datalinkage[lke].condition.contrastvalue, $("#" + datalinkage[lke].linkagecontrol), datalinkage[lke].linkageevent);
                                    }
                                    //渲染数据
                                    form.render();

                                }





                                break;
                            case 'switch':

                                if (!IsEmpty(inpdom.attr("lay-value")) && inpdom.attr("lay-value").split('|').length > 1) {

                                    inpdom.prop('checked', ((newFormEditor.values[data.id].value == inpdom.attr("lay-value").split('|')[0]) ? true : false));
                                }
                                else {
                                    inpdom.prop('checked', ((newFormEditor.values[data.id].value == 'true' || newFormEditor.values[data.id].value == 'on') ? true : false));
                                }

                                break;
                            case 'radio':
                                if (!IsEmpty(newFormEditor.values[data.id].value)) {
                                    inpdom.val([newFormEditor.values[data.id].value]);
                                }
                                else {
                                    inpdom.val([]);
                                }

                                break;
                            case 'user':
                            case 'dict':
                                inpdom.attr("ts-selected", newFormEditor.values[data.id].value);
                                inpdom.val(newFormEditor.values[data.id].text);
                                break;
                            case 'select':
                                if ((data.isowndefinition == true || data.isowndefinition == 'true') && newFormEditor.values[data.id].value.toLowerCase() === 'owndefinition') {
                                    //自定义数据
                                    //text值
                                    //inpdom.next('.layui-form-select').children('.layui-select-title').children('input').val(newFormEditor.values[data.id].value.text);
                                    //$(inpdom.next('.layui-form-select').children('dl').children('dd')[1]).children('input').val(newFormEditor.values[data.id].value.text);

                                    $(inpdom.children('option')[1]).text(newFormEditor.values[data.id].text);
                                }

                                inpdom.val(newFormEditor.values[data.id].value);
                                break;
                            default:
                                inpdom.val(newFormEditor.values[data.id].text);
                                //执行计算
                                totaltocontrolstotaltocontrols(inpdom);
                                break;
                        }
                    }

                    //对操作对象的渲染 输入对象
                    switch (data.tag) {
                        //渲染人员选择
                        case 'user':
                            var deptCode = [], roleGroupCode = [];

                            if (!IsEmpty(data.userdept) && data.userdept.hasOwnProperty("value")) {
                                deptCode = data.userdept.value.split(",");
                            }

                            if (!IsEmpty(data.rolegroup) && data.rolegroup.hasOwnProperty("value")) {
                                roleGroupCode = data.rolegroup.value.split(",");
                            }

                            userTableSelect.render({
                                key: inpdom,
                                deptCode: deptCode,
                                roleGroupCode: roleGroupCode,
                                type: data.selecttype
                            });
                            break;

                        case 'dict':
                            //渲染字典选择
                            if (!IsEmpty(data.dictclass)) {
                                dictTableSelect.render({
                                    key: inpdom,
                                    sysDictClassCode: data.dictclass,
                                    type: data.selecttype
                                });
                            }
                            break;
                        default:
                    }
                }

            }


            switch (data.tag) {
                //外层渲染
                case 'select':
                    form.render('select', renderName);
                    break;
                case 'radio':
                    form.render('radio', renderName);
                    break;
                case 'checkbox':
                case 'switch':
                    form.render('checkbox', renderName);
                    break;
                case 'date':
                    //渲染日期
                    laydate.render({
                        elem: inpdom[0],//'#date_' + data.id,
                        type: data.datetype || 'date',
                        range: data.daterange || false,
                        format: data.dateformat || 'yyyy-MM-dd'
                    });
                    break;
                default:
                    break;
            }
        }
        /**
         * 校验是否为数字
         * @param {any} val
         */
        function isNumber(val) {

            var regPos = /^\d+(\.\d+)?$/; //非负浮点数
            var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
            if (regPos.test(val) || regNeg.test(val)) {
                return true;
            } else {
                return false;
            }

        }

        //文本框数据校验长度校验位数校验
        function textdataverification(textdom) {

            textdom.removeClass("layui-form-danger");
            if (IsEmpty(textdom.val())) {
                return;
            }
            //数据类型
            var thistextdatatype = textdom.data("textdatatype");
            //数据位数
            var thistextdatalength = textdom.data("textdatalength");
            //最大值
            var thisnumbermax = textdom.data("numbermax");
            //最小值
            var thisnumbermin = textdom.data("numbermin");


            switch (thistextdatatype) {
                case "float":
                    //浮点型
                    var pattern = /^(-?\d+)(\.\d+)?$/,
                        str = textdom.val();
                    var isbaifenhao = false;
                    if (str.length === 1 + str.indexOf('%')) {
                        str = str.slice(0, str.length - 1)
                        isbaifenhao = true;
                    }

                    if (!pattern.test(str)) {

                        layer.tips('请输入数字或浮点数！', textdom, {
                            tips: 1
                        });


                        textdom.addClass("layui-form-danger");
                        textdom.focus();
                        return;
                    }

                    //校验位数
                    if (!IsEmpty(thistextdatalength) && isNumber(thistextdatalength)) {
                        //校验保留位数
                        if (str.indexOf('.') < 0) {
                            str = str+".";
                            //补齐
                            for (var i = 0; i < parseInt(thistextdatalength); i++) {
                                str = str + "0";
                            }
                            textdom.val(str + (isbaifenhao?"%":""));
                        }
                        else if (((str.length - str.indexOf('.')) - 1) > parseInt(thistextdatalength)) {

 
                            layer.tips('小数点位数最大！', textdom, {
                                tips: 1
                            });

                            textdom.addClass("layui-form-danger");
                            textdom.focus();
                            return;


                        }
                        else if (((str.length - str.indexOf('.')) - 1) < parseInt(thistextdatalength)) {
                            //少位数补齐
                            //当前位数
                            var dqws = ((str.length - str.indexOf('.')) - 1) < parseInt(thistextdatalength);
                            //缺少位数
                            var qsws = parseInt(thistextdatalength) - dqws;

                            for (var i = 0; i < qsws; i++) {
                                str = str + "0";
                            }
                            textdom.val(str + (isbaifenhao ? "%" : ""));

                        }
                    }
                    //校验最大值
                    if (!IsEmpty(thisnumbermax) && isNumber(thisnumbermax)) {
                        if (parseFloat(str) > parseFloat(thisnumbermax)) {
                            //不符合

                            layer.tips('最大值：' + thisnumbermax, textdom, {
                                tips: 1
                            });

                            textdom.addClass("layui-form-danger");
                            textdom.focus();
                            return;

                        }
                    }
                    //校验最小值
                    if (!IsEmpty(thisnumbermin) && isNumber(thisnumbermin)) {
                        if (parseFloat(str) < parseFloat(thisnumbermin)) {
                            //不符合

                            layer.tips('最小值：' + thisnumbermin, textdom, {
                                tips: 1
                            });

                            textdom.addClass("layui-form-danger");
                            textdom.focus();
                            return;

                        }
                    }



                    break;
                case "integer":
                    //整数型
                    var pattern = /^-?\d+$/,
                        str = textdom.val();
                    if (str.length === 1+str.indexOf('%')) {
                        str = str.slice(0, str.length - 1)
                    }

                    if (!pattern.test(str)) {
                        //请输入

                        layer.tips('请输入整数！', textdom, {
                            tips: 1
                        });

                        textdom.focus();
                        textdom.addClass("layui-form-danger");
                        return;

                    }

                    //校验长度
                    if (!IsEmpty(thistextdatalength) && isNumber(thistextdatalength)) {
                        if (textdom.val().length > parseInt(thistextdatalength)) {


                            layer.tips('整数最大位数是' + thistextdatalength + "位！", textdom, {
                                tips: 1
                            });


                            textdom.focus();
                            textdom.addClass("layui-form-danger");
                            return;

                        }
                    }


                    //校验最大值
                    if (!IsEmpty(thisnumbermax) && isNumber(thisnumbermax)) {
                        if (parseInt(str) > parseInt(thisnumbermax)) {
                            //不符合

                            layer.tips('最大值：' + thisnumbermax, textdom, {
                                tips: 1
                            });

                            textdom.addClass("layui-form-danger");
                            textdom.focus();
                            return;

                        }
                    }
                    //校验最小值
                    if (!IsEmpty(thisnumbermin) && isNumber(thisnumbermin)) {
                        if (parseInt(str) < parseInt(thisnumbermin)) {
                            //不符合

                            layer.tips('最小值：' + thisnumbermin, textdom, {
                                tips: 1
                            });

                            textdom.addClass("layui-form-danger");
                            textdom.focus();
                            return;

                        }
                    }

                    break;
                default:
                    //校验长度
                    if (!IsEmpty(thistextdatalength) && isNumber(thistextdatalength)) {
                        if (textdom.val().length > parseInt(thistextdatalength)) {


                            layer.tips('文字最大长度是' + thistextdatalength + "位！", textdom, {
                                tips: 1
                            });

                            textdom.focus();
                            textdom.addClass("layui-form-danger");
                            return;

                        }
                    }

                  
                    break;
            }


        }

        /**
         * 事件操作
         * @param {any} linkagevalue 当前控件值
         * @param {any} fuhao 对比符号
         * @param {any} contrastvalue 比较值
         * @param {any} controldom 操作控件
         * @param {any} linkageevent 事件类型
         */
        function controlevent(linkagevalue, fuhao, contrastvalue, controldom, linkageevent) {

            if (IsEmpty(controldom)) {
                return;
            }
            var issuccess = false;
            switch (fuhao) {
                case "=":
                    //等于
                    if (linkagevalue === contrastvalue || linkagevalue == contrastvalue) {
                        //符合
                        issuccess = true;
                    }
                    break;
                case "!=":
                    //不等于
                    if (linkagevalue !== contrastvalue || linkagevalue != contrastvalue) {
                        //符合
                        issuccess = true;
                    }
                    break;
                case ">":
                    //大于
                    //校验数据类型
                    if (isNumber(linkagevalue) && parseFloat(linkagevalue) > linkagevalue(contrastvalue)) {

                        issuccess = true;

                    }
                    break;
                case "<":
                    //小于
                    if (isNumber(linkagevalue) && parseFloat(linkagevalue) < linkagevalue(contrastvalue)) {

                        issuccess = true;

                    }
                    break;
                default:
            }

            if (issuccess) {

                switch (linkageevent) {
                    case "hide":
                        controldom.hide();
                        break;
                    case "display":
                        //显示
                        controldom.show();
                        break;
                    default:
                }

            }




        }


        /**
         * 合计，百分比
         * @param {any} inpdompar input dom
         */
        function totaltocontrolstotaltocontrols(inpdompar)
        {
            function formatNum(f, digit) {
                var m = Math.pow(10, digit);
                return Math.round(f * m) / m;
            }

                //获取合计数据
            var thistotaltocontrols = inpdompar.data("totaltocontrols");
            var thisName = inpdompar.attr("name");
                var value = inpdompar.val();

                var proportionto = '';
                if (!IsEmpty(thistotaltocontrols)) {
                    //循环处理累计
                    for (var i in thistotaltocontrols) {
                        if (IsEmpty(thistotaltocontrols[i])) {
                            continue;
                        }

                        if (!IsEmpty(thistotaltocontrols[i].text)) {
                            var isfind = false;
                            //修改累计数据
                            for (var s in newFormEditor.totalToIdValue) {
                                if (s == thistotaltocontrols[i].text) {
                                    //找到要累计到某控件的键
                                    isfind = true;
                                    break;
                                }
                            }
                            //存在
                            if (!isfind) {
                                //不存在添加一条 到某某控件的key
                                newFormEditor.totalToIdValue[thistotaltocontrols[i].text] = {};
                            }

                            //赋值 更改值
                            if (!isNaN(value)) {
                                //数字类型
                                newFormEditor.totalToIdValue[thistotaltocontrols[i].text][thisName] = { total: Number(value), proportion: 0 };
                            }
                            else {
                                newFormEditor.totalToIdValue[thistotaltocontrols[i].text][thisName] = { total: 0, proportion: 0 };
                            }

                            var totalCount = 0;
                            //查找到某某控件是否有本控件值
                            for (var f in newFormEditor.totalToIdValue[thistotaltocontrols[i].text]) {

                                totalCount = (Number(newFormEditor.totalToIdValue[thistotaltocontrols[i].text][f].total) + totalCount);
                            }

                            //计算百分比
                            for (var ll in newFormEditor.totalToIdValue[thistotaltocontrols[i].text]) {


                                var Divisor = newFormEditor.totalToIdValue[thistotaltocontrols[i].text][ll].total;

                                var proportion = 0;
                                if (totalCount > 0 && Divisor > 0) {
                                    proportion = (Divisor / totalCount) * 100;

                                }
                                newFormEditor.totalToIdValue[thistotaltocontrols[i].text][ll].proportion = proportion;

  
                               
                            }


                            //查找合计到的控件
                            newFormEditor.container.find("input[name='" + thistotaltocontrols[i].text + "']").each(function () {
                                $(this).val(totalCount);
                                //解决不输入也计算
                                totaltocontrolstotaltocontrols($(this));

                              
                                //重新计算百分比

                                var totalproportion = $(this).data("totalproportion");

                                if (!IsEmpty(totalproportion) && totalproportion.length > 0 && !IsEmpty(totalproportion[0])) {
                                    for (var p in totalproportion) {
                                        if (IsEmpty(totalproportion[p])) {
                                            continue;
                                        }
                                        if (newFormEditor.totalToIdValue[thistotaltocontrols[i].text].hasOwnProperty(totalproportion[p].proportionsource)) {

                                            newFormEditor.container.find("input[name='" + totalproportion[p].proportionto + "']").each(function () {


                                                //      textdatatype:45,
                                                //数据长度，整数长度，浮点保留位数
                                                //textdatalength: 46

                                                var baifenbi = newFormEditor.totalToIdValue[thistotaltocontrols[i].text][totalproportion[p].proportionsource].proportion+"";


                                                
                                                if ($(this).data("textdatatype") === 'integer') {

                                                    baifenbi = formatNum(baifenbi, 0);
                                                }
                                                else if ($(this).data("textdatatype") === 'float') {
                                                    var weishu = 1;

                                                    if (isNumber($(this).data("textdatalength"))) {

                                                        weishu = formatNum($(this).data("textdatalength"), 0);
                                                    }


                                                    if (baifenbi.indexOf('.') > 0) {
                                                        //有小数点
                                                        var xiaoshuweishu = (baifenbi.length - baifenbi.indexOf('.')) - 1
                                                        if (xiaoshuweishu > weishu) {
                                                            baifenbi = formatNum(baifenbi, weishu);
                                                        }
                                                        else {
                                                            //补全
                                                            for (var hh = 0; hh < weishu - xiaoshuweishu; hh++) {
                                                                baifenbi = baifenbi + "0";
                                                            }
                                                        }
                                                    }
                                                    else {
                                                        //补全位数
                                                        baifenbi = baifenbi + ".";
                                                        for (var jj = 0; jj < weishu; jj++) {
                                                            baifenbi = baifenbi + "0";
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    //默认1位
                                                    baifenbi = formatNum(baifenbi, 1);
                                                }

                                                $(this).val(baifenbi + ((totalproportion[p].percentsign === true || totalproportion[p].percentsign === 'true' || totalproportion[p].percentsign === 'on') ? '%' : ''));
                                                
                                            });
                                        }


                                    }

                                    /*
                                    for (var p in totalproportion) {
                                        if (IsEmpty(totalproportion[p])) {
                                            continue;
                                        }
                                        //查找当前控件值

                                            //除数
                                            var Divisor = 0;

                                        if (!isNaN(newFormEditor.totalToIdValue[thistotaltocontrols[i].text][totalproportion[p].proportionsource])) {
                                                Divisor = newFormEditor.totalToIdValue[thistotaltocontrols[i].text][totalproportion[p].proportionsource];
                                            }

                                            var proportion = 0;
                                            if (totalCount > 0 && Divisor > 0) {
                                                proportion = (Divisor / totalCount) * 100;
                                                
                                            }

                                            newFormEditor.container.find("input[name='" + totalproportion[p].proportionto + "']").each(function ()
                                            {
                                                $(this).val(formatNum(proportion, 1) + '%');

                                            });
                                        
                                    }
                                    */




                                }






                            });



                        }
                    }



                }
            
        }


        return div;
    }

    

    /**
     * 加载控件
     * @param {any} opt 参数
     */
    formEditor.prototype.loadControl = function (opt) {

        this.values = opt.value || this.values;
        this.callback = opt.callback;
        //清空数据
        this.putjson = [];
        var div = null;
        if (opt.type === editorformstate.repair) {
            div = $('#' + this.thisdivid);
        }
        else {
            div = this.container;
        }

        for (var i in opt.data) {
            var divchildren = $(document.createElement("div"));
            div.append(divchildren);

            //初始化控件数据
            this.createcontrol(divchildren, opt.data[i], opt.type, this.putjson, this.thisdivid);
        }



        /**编辑器对象 */
        var newFormEditor = this;

        switch (opt.type) {
            case editorformstate.edit:

                var btndiv = $(document.createElement("div"));
                btndiv.addClass("layui-form-item");
                btndiv.css("text-align", "center");
                btndiv.attr("id", "btnoperation"); 
                div.append(btndiv);


                if (!IsEmpty(opt.callback)) {

                    if (typeof opt.callback.save === 'function') {

                        var btnhtml = '<button id="formEditorSave"  class="layui-btn layui-btn-radius" style="width: 180px; height: 50px;"  type="button" lay-filter="save">保存</button>';
                        btndiv.append(btnhtml);

                        $('#formEditorSave').on('click', function () {
                            opt.callback.save(newFormEditor.val());
                        });
                    }

                    if (typeof opt.callback.submit === 'function') {
                        var btnhtml = '<button id="formEditorSubmit" lay-submit="" class="layui-btn layui-btn-normal layui-btn-radius" style="width: 180px; height: 50px;"  type="submit"  lay-filter="formEditorSubmit">提交</button>';
                        btndiv.append(btnhtml);
                        //验证提交
                        form.on('submit(formEditorSubmit)', function (data) {
                            opt.callback.submit(newFormEditor.val());
                            return false;
                        });
                        /*
                        $('#formEditorSubmit').on('click', function () {
                            //校验数据

                            opt.callback.submit(newFormEditor.val());
                            return false;
                        });
                        */
                    }



                    /*
                    if (typeof opt.callback.reset === 'function') {
                        var btnhtml = '<button id="formEditorReset" class="layui-btn layui-btn-danger layui-btn-radius" type="button" lay-filter="reset">重置</button>';
                        btndiv.append(btnhtml);

                        $('#formEditorReset').on('click', function () {

                            opt.callback.reset(newFormEditor.val());

                            /**
                            * 递归 获取默认值
                            * @param {any} json json重置数据集合
                            * @param {any} putjson 控件集合
                            */
                            /*
                            function setdefaulttext(json, putjson) {
                                if (IsEmpty(putjson)) {
                                    return;
                                }

                                for (var f in putjson) {
                                    if (IsEmpty(f)) {
                                        continue;
                                    }

                                    json[putjson.id] = putjson.defaulttext || '';
                                    if (putjson[f].hasOwnProperty("controls") && !IsEmpty(putjson[f].controls)) {
                                        setdefaulttext(json, putjson[f].controls);
                                    }
                                }
                            }

                            //生成新的对象 为了解决重置初始值问题
                            var valuesjson = {};
                            if (IsEmpty(newFormEditor.values)) {
                                setdefaulttext(valuesjson, putjson)
                            }
                            else {
                                valuesjson = newFormEditor.values
                            }

                            newFormEditor.val(valuesjson);
                        });

                    }
                    */



                    //导出Excel  exportExcel formEditorexportExcel
                    var btnexcelhtml = '<button id="formEditorexportExcel"  class="layui-btn layui-btn-radius" style="width: 180px; height: 50px;"  type="button" lay-filter="excel">导出Excel</button>';

                    btndiv.append(btnexcelhtml);
                    $('#formEditorexportExcel').on('click', function () {
                        newFormEditor.exportExcel();
                    });


                    if (typeof opt.callback.cancel === 'function') {
                        var btnhtml = '<button id="formEditorCancel" class="layui-btn layui-btn-primary layui-btn-radius" style="width: 180px; height: 50px;"  type="button" lay-filter="cancel">取消</button>';
                        btndiv.append(btnhtml);

                        $('#formEditorCancel').on('click', function () {
                            opt.callback.cancel(newFormEditor.val());
                        });

                    }
                }

                break;
            case editorformstate.read:
                var btndiv = $(document.createElement("div"));
                btndiv.addClass("layui-form-item");
                btndiv.css("text-align", "center");
                btndiv.attr("id","btnoperation"); 
                div.append(btndiv);
                if (!IsEmpty(opt.callback)) {

                    if (typeof opt.callback.examineadopt === 'function') {
                        var btnhtml = '<button id="formEditorExamineAdopt" class="layui-btn layui-btn-normal layui-btn-radius" style="width: 180px; height: 50px;"  type="button" lay-filter="formEditorExamineAdopt">通过</button>';
                        btndiv.append(btnhtml);
                        $('#formEditorExamineAdopt').on('click', function () {
                            opt.callback.examineadopt(newFormEditor.TemplateID);
                        });
                    }
                    //审核不通过

                    if (typeof opt.callback.examinenoadopt === 'function') {
                        var btnhtml = '<button id="formEditorExamineNoAdopt" class="layui-btn layui-btn-danger layui-btn-radius" style="width: 180px; height: 50px;"  type="button" lay-filter="formEditorExamineNoAdopt">退回</button>';
                        btndiv.append(btnhtml);
                        $('#formEditorExamineNoAdopt').on('click', function () {
                            opt.callback.examinenoadopt(newFormEditor.TemplateID);
                        });
                    }

                    /*导出PDF*/
                    
                    var btnhtml = '<button id="formEditorexportPdf"  class="layui-btn layui-btn-radius" style="width: 180px; height: 50px;"  type="button" lay-filter="pdf">导出PDF</button>';
                    btndiv.append(btnhtml);
                    $('#formEditorexportPdf').on('click', function () {
                        newFormEditor.exportPdf();
                    });

                    //导出Excel  exportExcel formEditorexportExcel
                    var btnexcelhtml = '<button id="formEditorexportExcel"  class="layui-btn layui-btn-radius" style="width: 180px; height: 50px;"  type="button" lay-filter="excel">导出Excel</button>';

                    btndiv.append(btnexcelhtml);
                    $('#formEditorexportExcel').on('click', function () {
                        newFormEditor.exportExcel();
                    });


                    if (typeof opt.callback.cancel === 'function') {
                        var btnhtml = '<button id="formEditorCancel" class="layui-btn layui-btn-primary layui-btn-radius" type="button" style="width: 180px; height: 50px;"  lay-filter="cancel">取消</button>';
                        btndiv.append(btnhtml);

                        $('#formEditorCancel').on('click', function () {
                            opt.callback.cancel(newFormEditor.val());
                        });



                    }
                }
                break;
            default:
        }



        //渲染
        // form.render(null, this.thisdivid)
    };
    /**编辑模式 预览 数据 */
    formEditor.prototype.preview = function () {
        //预览数据 编辑状态预览
        if (this.editortype !== editorformstate.repair) {
            layer.msg('非维护状态，不可以预览数据', {
                icon: 2,
                time: 3000
            });
            return;
        }
        var json = this.getJson();
        if (IsEmpty(json)) {
            layer.msg('无任何数据', {
                icon: 2,
                time: 3000
            });
            return;
        }


        //用于存放生成的数据
        var div = $(document.createElement("div"));
        div.attr("id", "editor_preview");
        div.attr("lay-filter", "editor_preview");
        div.addClass("layui-form");
        div.css("padding-right", "20px");

        $('body').append(div);
        var arr = [];
        for (var i in json) {

            var divchildren = $(document.createElement("div"));
            div.append(divchildren);

            //初始化数据
            this.createcontrol(divchildren, json[i], editorformstate.edit, arr, 'editor_preview');
        }

        layer.open({
            type: 1,
            title: '预览模板',
            shadeClose: true,
            area: ['700px', '450px'],
            shade: 0.8,
            fixed: false, //不固定
            resize: true,
            maxmin: true
            , moveType: 1,
            content: div,
            success: function (layero, index) {
                layer.full(index);
                //form.render(null, "editor_preview");
            },
            end: function () {
                div.remove();
            }

        });

    }

    /**编辑模式 导出json 弹框数据 */
    formEditor.prototype.exportJson = function () {
        if (this.editortype !== editorformstate.repair) {
            layer.msg('非维护状态，不可以导出json', {
                icon: 2,
                time: 3000
            });
            return;
        }

        var getjson = this.getJson();
        if (IsEmpty(getjson)) {
            layer.msg('无任何数据', {
                icon: 2,
                time: 3000
            });
            return;
        }

        layer.open({
            type: 1,
            title: '导出模板json',
            shadeClose: true,
            area: ['700px', '450px'],
            shade: 0.8,
            fixed: false, //不固定
            resize: true,
            maxmin: true
            , moveType: 1,
            content: '<pre class="layui-code" style="overflow: auto;">' + JSON.stringify(this.getJson(), null, 4) + '</pre>'
        });

    }

    /**导出json */
    formEditor.prototype.getJson = function () {

        var thisputjson;
        if (arguments != null && arguments.length > 0  && Array.isArray(arguments[0])) {
            thisputjson = arguments[0]

        } else {
            thisputjson = this.putjson;
        }
        var retputjson = [];
        for (var i in thisputjson) {
            retputjson.push({});
            for (var f in thisputjson[i]) {
                if (f !== 'tagdom' && f !== 'domtype') {
                    retputjson[i][f] = thisputjson[i][f];
                }
            }
            if (retputjson[i].hasOwnProperty("controls") && !Auxiliary.IsEmpty(retputjson[i].controls)) {
                retputjson[i].controls = this.getJson(retputjson[i].controls);
            }
        }

        return retputjson;
    }


    /*保存模板*/
    formEditor.prototype.saveTemplate = function () {
        if (!IsEmpty(this.callback)) {

            if (typeof this.callback.saveTemplate === 'function') {
                this.callback.saveTemplate(this.getJson());
            }

        }
    }



    /**
     * 取值,赋值
     * @param {any} object 编辑器值 主要用于重置数据
     * @递归列表
     */

    //赋值/取值
    formEditor.prototype.val = function (object) {
        //主要取值，判断是否存在验证项
        //form.val(this.thisdivid, object);

        if (IsEmpty(object)) {
            //为了 可以进行验证数据，调用一次layui 提交的验证
            //form.val(this.thisdivid);
            //取值
           return this.recursionval(this.putjson, object);
        }
        else
        {
            //赋值  暂时用不到 先不写了
            
        }
    };

    /**
     * 赋值 取值
     * @param {any} ControlList 控件集合
     * @param {any} object 赋值的值
     */
    formEditor.prototype.recursionval = function (ControlList, object) {
        var retdata = {};
        //取值

        for (var i in ControlList) {
            //赋值 暂时不用，主要我没调试呢，写了  没用过，用的form自带的赋值
            var ControlTextValue = null;//赋值用不到  当前变量值
            if (!IsEmpty(object) && object.hasOwnProperty(ControlList[i].id)) {
                //搜搜当前key
                ControlTextValue = object[ControlList[i].id];

            }

            if (ControlList[i].tag != 'row' && ControlList[i].tag != 'title') {
                var value = this.GetSetControlData(ControlList, ControlList[i].id, ControlTextValue);
               // if (!IsEmpty(value)) {
                    retdata[ControlList[i].id] = value;
                //}


            } else if (ControlList[i].tag == 'row' && !IsEmpty(ControlList[i].controls)) {
                //多条数据模式，取行内多条数据
                if (ControlList[i].issureaddmultiple === true || ControlList[i].issureaddmultiple === 'true' || ControlList[i].issureaddmultiple === 'on') {
                    //动态添加数据模式
                    //获取行数
                    var value = this.GetSetControlData(ControlList, ControlList[i].id, ControlTextValue);
                    //if (!IsEmpty(value)) {
                        retdata[ControlList[i].id] = value;
                    //}

                    //获取控件下内容
                    var values1 = this.recursionval(ControlList[i].controls, object);

                    if (!IsEmpty(values1)) {
                        for (var s in values1) {
                            retdata[s] = values1[s];
                        }
                    }
                    //赋值动态列表
                    if (parseInt(value.value) > 1) {
                        for (var hh = 0; hh < (parseInt(value.value) - 1); hh++) {
                            var DynamicControlsList = JSON.parse(JSON.stringify(ControlList[i].controls));

                            //更改ID
                            for (var fff in DynamicControlsList) {
                                DynamicControlsList[fff].id = DynamicControlsList[fff].id + "_dynamic_" + hh;
                            }

                            //取值
                            var values2 = this.recursionval(DynamicControlsList, object);
                            if (!IsEmpty(values2)) {
                                for (var k in values2) {
                                    retdata[k] = values2[k];
                                }
                            }

                        }
                    }


                }
                else {
                    //非动态添加数据模式
                    var values = this.recursionval(ControlList[i].controls, object);

                    if (!IsEmpty(values)) {
                        for (var s in values) {
                            retdata[s] = values[s];
                        }
                    }



                }
            }

        }
        return retdata;
    };



    /**
     * 循环递归赋值，单个赋值
     * 赋值或获取表单内容
     * @param {any} ControlList 控件集合
     * @param {any} Controlid 控件ID
     * @param {any} data 要赋值的值
     */
    formEditor.prototype.GetSetControlData = function (ControlList,Controlid,data)
    {
        if (!IsEmpty(ControlList)) {

            for (var item in ControlList) {
                if (IsEmpty(ControlList[item])) {
                    continue;
                }
                if (ControlList[item].id == Controlid &&
                    ControlList[item].tag == "row" &&
                    (ControlList[item].issureaddmultiple === true || ControlList[item].issureaddmultiple ==='true' || ControlList[item].issureaddmultiple ==='on')) {
                    //多行模式
                    //  var datalength = parentDiv.data("datalistlength");
                    if (IsEmpty(data)) {
                        var datalength = this.container.find("#" + ControlList[item].id).data("datalistlength");
                        if (IsEmpty(datalength)) {
                            datalength = 0;
                        }
                        datalength = parseInt(datalength)+1
                        return { text: datalength, value: datalength };
                    }
                    else
                    {
                        //赋值
                        this.container.find("#" + ControlList[item].id).data("datalistlength", data.value);
                    }
                    return;

                }


                if (ControlList[item].id == Controlid && ControlList[item].tag != "row" && ControlList[item].tag!="title") {

                    switch (ControlList[item].tag) {
                        case "select":
                            if (IsEmpty(data)) {
                                //取值
                                var select = this.container.find("select[name='" + ControlList[item].id + "']").next().children("dl").children(".layui-this");
                                if (!IsEmpty(select)) {
                                    //lay-value
                                    if (select.children('input').length>0) {
                                        return { text: this.container.find("select[name='" + ControlList[item].id + "']").next().children("div").children("input").val(), value: select.attr("lay-value") };
                                    }

                                    return { text: select.text(), value: select.attr("lay-value") };
                                }

                                return { text: null,value: null};
                            }
                            else
                            {

                                var select = this.container.find("select[name='" + ControlList[item].id + "']").next().children("dl").children("dd").each(function ()
                                {

                                    if ($(this).attr("lay-value") == data.value) {
                                        $(this).addClass("layui-this");
                                        //判断是否是自定义数据




                                        return;
                                    }
                                });
                                return;
                            }
                            break;
                        case "radio":


                            if (IsEmpty(data)) {
                                var text1 = "";
                                var value1 = "";
                                this.container.find(":input[name='" + ControlList[item].id + "']").each(function () {

                                    if ($(this).next().hasClass("layui-form-radioed")) {
                                        //选中
                                        text1 = text1 + $(this).attr("title") + ",";
                                        value1 = value1 + $(this).val() + ",";
                                    }
                                });
                                if (text1.length > 0 && value1.length > 0) {
                                    text1 = text1.substr(0, text1.length - 1);
                                    value1 = value1.substr(0, value1.length - 1);
                                }
                                //取值
                                return { text: text1, value: value1 };
                            }
                            else {
                                var valuelist = [];
                                if (data.value.indexOf(",") != -1) {
                                    valuelist = data.value.split(',');
                                }
                                else {
                                    valuelist[0] = data.value;
                                }

                                this.container.find(":input[name='" + ControlList[item].id + "']").each(function () {
                                    $(this).next().removeClass("layui-form-radioed");

                                    for (var i in valuelist) {
                                        //判断是否选中是否存在
                                        if ($(this).val() == i) {
                                            //需要被选中
                                            if (!$(this).next().hasClass("layui-form-radioed")) {
                                                //不等于选中状态
                                                $(this).next().addClass("layui-form-radioed");
                                            }
                                        }
                                    }

                                });
                                return;
                            }



                            break;
                        case "checkbox":
                            if (IsEmpty(data)) {
                                var text = "";
                                var value = "";
                                this.container.find(":input[name='" + ControlList[item].id + "']").each(function () {

                                    if ($(this).next().hasClass("layui-form-checked")) {
                                        //选中
                                        text = text + $(this).attr("title") + ",";
                                        value = value + $(this).val() + ",";
                                    }
                                });
                                if (text.length > 0 && value.length>0) {
                                    text = text.substr(0, text.length - 1);
                                    value = value.substr(0, value.length - 1);
                                }
                                //取值
                                return { text: text, value: value };
                            }
                            else {
                                var valuelist = [];
                                if (data.value.indexOf(",") != -1) {
                                    valuelist = data.value.split(',');
                                }
                                else {
                                    valuelist[0] = data.value;
                                }

                                this.container.find(":input[name='" + ControlList[item].id + "']").each(function () {
                                    $(this).next().removeClass("layui-form-checked");
                                    
                                    for (var i in valuelist) {
                                          //判断是否选中是否存在
                                        if ($(this).val() == i) {
                                            //需要被选中
                                            if (!$(this).next().hasClass("layui-form-checked")) {
                                                //不等于选中状态
                                                $(this).next().addClass("layui-form-checked");
                                            }
                                        }
                                    }

                                }); 
                                return;
                            }

                            break;
                        case "switch":

                            if (IsEmpty(data)) {
                                var text2 = "";
                                var value2 = "";
                                this.container.find(":input[name='" + ControlList[item].id + "']").each(function () {

                                    if ($(this).next().hasClass("layui-form-onswitch")) {
                                        //选中
                                        text2 = $(this).attr("lay-text").split('|')[0];

                                        if (!IsEmpty($(this).attr("lay-value")) && $(this).attr("lay-value").split('|').length > 1) {
                                            //取隐藏值
                                            value2 = $(this).attr("lay-value").split('|')[0];
                                        }
                                        else {
                                            value2 = "true";
                                        }

                                       
                                    }
                                    else
                                    {
                                        //没选中
                                        text2 = $(this).attr("lay-text").split('|')[1];
                                        //取隐藏值
                                        if (!IsEmpty($(this).attr("lay-value")) && $(this).attr("lay-value").split('|').length > 1) {
                                            //取隐藏值
                                            value2 = $(this).attr("lay-value").split('|')[1];
                                        }
                                        else {
                                            value2 = "false";
                                        }
                                    }

                                });
                                //取值
                                return { text: text2, value: value2 };
                            }
                            else {

                                this.container.find(":input[name='" + ControlList[item].id + "']").each(function () {
                                    var rvalue = "true";
                                    if (!IsEmpty($(this).attr("lay-value")) && $(this).attr("lay-value").split('|').length > 1) {

                                        rvalue = $(this).attr("lay-value").split('|')[0];
                                    }

                                    //判断是否选中是否存在
                                    if (data.value == rvalue) {
                                        //需要被选中
                                        if (!$(this).next().hasClass("layui-form-onswitch")) {
                                            $(this).next().addClass("layui-form-onswitch");
                                        }
                                    }

                                });
                                return;
                            }
                            break;
                        default:
                            //文本框
                            if (IsEmpty(data))
                            {
                                //取值
                                var textdom = this.container.find(":input[name='" + ControlList[item].id + "']");

                                return { text: textdom.val(), value: textdom.attr("ts-selected")}

                            } else
                            {
                                //赋值
                                this.container.find(":input[name='" + ControlList[item].id + "']").val(data.text);
                                if (!IsEmpty(data.value)) {
                                    this.container.find(":input[name='" + ControlList[item].id + "']").attr("ts-selected", data.value);
                                }
                            }
                            break;
                    }

                    if (!IsEmpty(ControlList[item].controls)) {
                        return GetSetControlData(ControlList[item].controls, Controlid, data);
                    }

                }


            }

        }
    }

    var Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function (e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function (e) { e = e.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function (e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } }

    /**
     * 导出PDF 
     */
    formEditor.prototype.exportPdf = function () {


        //加载图标
        var loadindex = layer.load(2, { time: 60 * 1000 });

        var url = "/Template/TemplateFormPdf",
            data = "",//encodeURIComponent(this.container.prop("outerHTML")),
            name = "导出PDF";
        var neorong = this.container.prop("outerHTML");
        var div = $(document.createElement("div"));
        div.html(neorong);
        //div.remove("#btnoperation");

        //把用户输入的值初始化进去


        var inputlist = this.container.find("input");
        for (var i = 0; i < inputlist.length; i++) {
            div.find("input[name='" + $(inputlist[i]).attr("name") + "']").attr("value", $(inputlist[i]).val());
            div.find("input[name='" + $(inputlist[i]).attr("name") + "']").removeAttr("disabled");
        }

        var textarealist = this.container.find("textarea");
        for (var i = 0; i < textarealist.length; i++) {
            div.find("textarea[name='" + $(textarealist[i]).attr("name") + "']").html($(textarealist[i]).val());
            div.find("textarea[name='" + $(textarealist[i]).attr("name") + "']").removeAttr("disabled");
        }


        var disabledlist = div.find(".layui-disabled");

        for (var i = 0; i < disabledlist.length; i++) {
            $(disabledlist[i]).removeClass("layui-disabled");
        }

        var layuiradiodisbaled = div.find(".layui-radio-disbaled");
        for (var i = 0; i < layuiradiodisbaled.length; i++) {
            $(layuiradiodisbaled[i]).removeClass("layui-radio-disbaled");
        }



        var layuicheckboxdisbaled = div.find(".layui-checkbox-disbaled");
        for (var i = 0; i < layuicheckboxdisbaled.length; i++) {
            $(layuicheckboxdisbaled[i]).removeClass("layui-checkbox-disbaled");
        }


        var layuiselectdisabled = div.find(".layui-select-disabled");
        for (var i = 0; i < layuiselectdisabled.length; i++) {
            $(layuiselectdisabled[i]).removeClass("layui-select-disabled");
        }




        //layui-select-disabled

        div.find("#btnoperation").remove();
        div.prepend("<div style='font-size:14px;font-weight:700;text-align:center;'>" + this.title+"</div>")
         

        data = encodeURIComponent(div.html());
        data = Base64.encode(data);
        function base64ToBlob(code) {
            //Base64一行不能超过76字符，超过则添加回车换行符。因此需要把base64字段中的换行符，回车符给去掉，有时候因为存在需要把加号空格之类的换回来，取决于base64存取时的规则。
            code = code.replace(/[\n\r]/g, '');
            var raw = window.atob(code);
            let rawLength = raw.length;
            //转换成pdf.js能直接解析的Uint8Array类型
            let uInt8Array = new Uint8Array(rawLength);
            for (let i = 0; i < rawLength; ++i) {
                uInt8Array[i] = raw.charCodeAt(i);
            }
            return new Blob([uInt8Array], { type: 'application/pdf' });//转成pdf类型
        }

        $.ajax({
            type: "post",
            url: url,
            data: { content:data  },
            success: function (msg) {
                layer.close(loadindex);
                if (msg.code != "0") {
                    layer.msg(msg.msg, {
                        icon: 2,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    });
                    return;
                }

                //打开PDF文件 msg.data.pdfBytes
                //获取到了blob对象
                var blob = base64ToBlob(msg.data.pdfBase64);
                //获取当前url，直接放到iframe就能用，下载同理
                //var blobURL = window.URL.createObjectURL(blob);
                var filename = new Date().getTime()+".pdf";
                // IE
                if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                    window.navigator.msSaveOrOpenBlob(blob, filename)
                } else {
                    const a = document.createElement('a');
                    a.download = filename;
                    a.style.display = 'none';
                    a.href = window.URL.createObjectURL(blob);
                    document.body.appendChild(a);
                    a.click();
                    a.remove();
                    //window.URL.revokeObjectURL(href);
                }

   
                /*
                layer.open({
                    type: 1,
                    title: name,
                    shadeClose: true,
                    area: ['700px', '450px'],
                    shade: 0.8,
                    fixed: false, //不固定
                    resize: true,
                    maxmin: true
                    , moveType: 1,
                    content: blobURL,
                    success: function (layero, index) {
                        layer.full(index);


                    },
                    end: function () {
                        
                    }

                });
                */



            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.close(loadindex);
                layer.msg('请求失败！', {
                    icon: 2,
                    time: 3000 //3秒关闭
                });
            }
        });


        /*
        var url = "/Template/TemplateFormPdf",
            data = "",//encodeURIComponent(this.container.prop("outerHTML")),
            name = "导出PDF";

        var neorong = this.container.prop("outerHTML");
        var div = $(document.createElement("div"));
        div.html(neorong);
        div.remove("#btnoperation");

        //把用户输入的值初始化进去


        var inputlist = this.container.find("input");
        for (var i = 0; i < inputlist.length; i++) {
            div.find("input[name='" + $(inputlist[i]).attr("name") + "']").attr("value",$(inputlist[i]).val());
        }

        data = div.html();

        var tempForm = document.createElement("form");
        tempForm.id = "tempForm1";
        tempForm.method = "post";
        tempForm.action = url;
        tempForm.target = name;    // _blank - URL加载到一个新的窗口

        var hideInput = document.createElement("input");
        hideInput.type = "hidden";
        hideInput.name = "content";
        hideInput.value = encodeURIComponent(data);

        tempForm.appendChild(hideInput);
        // 可以传多个参数
        /* var nextHideInput = document.createElement("input");
        nextHideInput.type = "hidden";
        nextHideInput.name = "content";
        nextHideInput.value = data;
        tempForm.appendChild(nextHideInput); */
        /*
        if (document.all) {    // 兼容不同浏览器
            tempForm.attachEvent("onsubmit", function () { });        //IE
        } else {
            tempForm.addEventListener("submit", function () { }, false);    //firefox
        }
        document.body.appendChild(tempForm);
        /*
        if (document.all) {    // 兼容不同浏览器
            tempForm.fireEvent("onsubmit");
        } else {
            tempForm.dispatchEvent(new Event("submit"));
        }
        */
        /*
        tempForm.submit();
        document.body.removeChild(tempForm);
        */

    }

    /**导出Excel文件 */
    formEditor.prototype.exportExcel = function ()
    {
        //加载图标
        var loadindex = layer.load(2, { time: 60 * 1000 });
        var parformEditor = this;
        //循环控件集合 this.putjson
        var exportExcelJson = LoopControlList(this.putjson);

            //taskformtable

        //调用
        layui.config({
            base: '/Scripts/Layui/excel/'
        }).use(['excel'], function () {
            var excel = layui.excel;
            var dataList = [];
            var datatitle = {};
            var datavalue = {};
           
            for (var i in exportExcelJson) {
                datatitle[i] = exportExcelJson[i].title;
                datavalue[i] = exportExcelJson[i].value;
            }

            if (IsEmpty(datatitle)) {
                layer.msg('模板无导出列,想要导出请联系管理员！', {
                    icon: 2,
                    time: 3000
                });
                layer.close(loadindex);
                return;
            }

             //创建标头
            dataList.push(datatitle);

            //创建数据
            dataList.push(datavalue);

          

            excel.downloadExcel(dataList, parformEditor.title, 'xlsx');

            layer.close(loadindex);
        });

       
       







        
        function LoopControlList(ControlList)
        {
            var retdata = {};
            //添加提交用户信息
            retdata['user_add_name_title'] = { title: '用户名称', value: parformEditor.taskformtable.taskAddUserName };

            //取值
            for (var i in ControlList) {
                if (ControlList[i].tag != 'row' && ControlList[i].tag != 'title' && ControlList[i].isexportexcel === true) {
                    //获取控件key和显示值
                    var value = parformEditor.GetSetControlData(ControlList, ControlList[i].id, null);
                    
                    if (typeof value === 'object' && value.hasOwnProperty("text") && value.hasOwnProperty("value")) {
                        value = value.text;
                    }
                    retdata[ControlList[i].id] = { title: ControlList[i].title, value: value };

                }
                else if (ControlList[i].tag == 'row' && !IsEmpty(ControlList[i].controls)) {
                    var values = LoopControlList(ControlList[i].controls);
                    for (var s in values) {
                        retdata[s] = values[s];
                    }
                }
            }
            return retdata;
        }

      
    }


    /**对外提供的方法 */
    var tt = {
        /**
         * 渲染
         * @param {any} opt
         */
        render: function (opt) {
            //加载层
            var loadindex = layer.load(2, { time: 20 * 1000 });

            if (opt.type !== editorformstate.repair && opt.type !== editorformstate.edit && opt.type !== editorformstate.read) {
                layer.msg('编辑器状态只能是,编辑：' + editorformstate.edit + ',阅读：' + editorformstate.read + ',维护：' + editorformstate.repair, {
                    icon: 2,
                    time: 3000
                });
                return;
            }
            if (IsEmpty(opt.elem)) {
                layer.msg('编辑器容器ID不能为空！elem参数 如：#id或者body或者.class', {
                    icon: 2,
                    time: 3000
                });
                layer.close(loadindex);
                return;
            }
            if (typeof opt.elem !== 'string') {
                layer.msg('编辑器容器参数错误！elem参数 如：#id或者body或者.class', {
                    icon: 2,
                    time: 3000
                });
                layer.close(loadindex);
                return;
            }

            //初始化数据
            opt.data = opt.data || [];
            var elem = $(opt.elem);

            if (elem.length < 1) {
                layer.msg('编辑器容器不存在 elem参数 如：#id或者body或者.class', {
                    icon: 2,
                    time: 3000
                });
                layer.close(loadindex);
                return;
            }

            //加载字典类型
            loadDictClassList(function ()
            {
                /*
                //加载用户类型
                new ajaxdict({ data: { dictclass: 'Department' } },
                    function (success, opt) {
                        if (!success) {
                            layer.close(loadindex);
                            return;
                        } 
                        //加载角色组
                        new ajaxdict({ data: { dictclass: 'RoleGroup' } },
                            function (success, opt) {

                                if (!success) {
                                    layer.close(loadindex);
                                    return;
                                } 

                                //初始化控件数据
                                initializationformeditor();
                            });
                    });
                    */
                //初始化控件数据
                initializationformeditor();



            });



            /**
             * 加载字典类型
             * @param {Function} mycallback
             */
            function loadDictClassList(mycallback)
            {

                if (dictClassList === null) {
                    $.ajax({
                        type: "post",
                        url: '/Template/GetSysDictClassCodeName.aspx',
                        success: function (msg) {
                            if (msg.code != "0" && msg.code != "-600") {
                                layer.msg(msg.msg, {
                                    icon: 2,
                                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                });
                                return;
                            }

                            if (msg.code == "-600") {
                                dictClassList = [];
                            }
                            else {
                                //加载数据
                                dictClassList = msg.data.list;
                            }
                            //回调
                            mycallback();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.msg('请求失败！', {
                                icon: 2,
                                time: 3000 //3秒关闭
                            });
                        }
                    });
                }
                else {
                    mycallback();
                }
            }



            /**初始化 */
            function initializationformeditor() {
                //获取编辑器
                var Form_Editor = formEditorContainer[opt.elem];
                if (IsEmpty(Form_Editor)) {
                    Form_Editor = new formEditor(opt.type, elem);

                    formEditorContainer[opt.elem] = Form_Editor;
                }
                if (Form_Editor.editortype === opt.type ||
                    ((editorformstate.edit === opt.type || editorformstate.read === opt.type)
                    && Form_Editor.editortype !== editorformstate.repair)
                ) {
                    Form_Editor.loadControl(opt);
                }
                else {
                    if (Form_Editor.editortype === editorformstate.repair) {
                        layer.msg('不可以把阅读编辑模式变成维护模式！,请设置为,编辑：' + editorformstate.edit + ',阅读：' + editorformstate.read, {
                            icon: 2,
                            time: 3000
                        });
                    }
                    else {
                        layer.msg('编辑器状态只能是维护状态,请设置为：维护：' + editorformstate.repair, {
                            icon: 2,
                            time: 3000
                        });
                    }
                }
                if (!IsEmpty(Form_Editor)) {
                    Form_Editor.title = opt.title;
                    Form_Editor.taskformtable = opt.taskformtable;
                }
                layer.close(loadindex);

            }



        }
        ,
        /**
         * 导出json数据 容器ID
         * @param {any} id
         */
        exportJson: function (id) {

            //生成json
            if (typeof id !== 'string') {
                layer.msg('编辑器容器ID不能为空！elem参数 如：#id或者body或者.class', {
                    icon: 2,
                    time: 3000
                });
                return;
            }

            if (IsEmpty(id)) {
                layer.msg('当前容器实例不存在！', {
                    icon: 2,
                    time: 3000
                });
                return;
            }

            var Form_Editor = null;
            if (formEditorContainer.hasOwnProperty(id)) {
                Form_Editor = formEditorContainer[id];
            }

            if (IsEmpty(Form_Editor)) {
                layer.msg('当前容器实例不存在！', {
                    icon: 2,
                    time: 3000
                });
                return;
            }
            return Form_Editor.getJson();
        }
        
    }
    exports('formEditor', tt);
});
